Author Topic: Well I'm doing:  (Read 1423 times)

0 Members and 1 Guest are viewing this topic.

Offline dominikkk26

  • Camper
  • ***
  • Posts: 404
    • PMGsite
Well I'm doing:
« on: December 28, 2009, 05:23:54 am »
Well I'm doing:
            //display stats
            DrawText(ID,'Kills: ' +nickName_Kills[ID],GOOD);(255,0,0),0.5,48,260);
            DrawText(ID,'Deaths: ' +nickName_Deaths[ID],GOOD);(255,0,0),0.5,48,260);
            DrawText(ID,'SelfKills: '+nickName_SelfKills[ID],GOOD);(255,0,0),0.5,48,260);

Code: (pascal) [Select]
function OnPlayerCommand(ID: Byte; Text: string): boolean;
var
inputNick, tempNick, InputPassword, InputPasswordLogin, nick: string;
currentDate: string;
begin
//displays player stats
if (Copy(Text,1,6) = '!stats') then
        begin
if GetPlayerStat(ID, 'Active') = true then
begin
nick := GetPlayerStat(ID,'name');

//check if player already got profile or not
if FileExists('stats/nickreg/'+filterFileName(nick)+'.txt') = true then
  begin
//load player profile
LoadNickname(FilterFilename(GetPlayerStat(ID,'name')),ID);

//display stats
DrawText(ID,'Kills: ' +nickName_Kills[ID],GOOD);(255,0,0),0.5,48,260);
DrawText(ID,'Deaths: ' +nickName_Deaths[ID],GOOD);(255,0,0),0.5,48,260);
DrawText(ID,'SelfKills: '+nickName_SelfKills[ID],GOOD);(255,0,0),0.5,48,260);

//check if player has more then 0 deaths otherwise its divide by zero
if strtoint(nickName_Deaths[ID]) > 0 then
begin
kdKills[ID] := strtoint(nickName_Kills[ID]);
kdDeaths[ID] := strtoint(nickName_Deaths[ID]);
kdRatio[ID] := kdKills[ID] / kdDeaths[ID];
WriteConsole(ID,'K/D Ratio: '+floattostr(roundto(kdRatio[ID],2)),GOOD);
end
end else
begin
WriteConsole(ID,'You do not have a profile!',BAD);
end
end
end

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: Well I'm doing:
« Reply #1 on: December 28, 2009, 06:22:50 am »
Command string in OnPlayerCommand never begins with '!' so it should be
Code: [Select]
if (Copy(Text,1,6) = '/stats') then

but since command always begins with '/' char
Code: [Select]
if (Copy(Text,2,5) = 'stats')is enough

Also if GetPlayerStat(ID, 'Active') = true then instruction is not needed because inactive player can't perform a command.
« Last Edit: December 28, 2009, 06:25:57 am by tk »

Offline dnmr

  • Camper
  • ***
  • Posts: 315
  • emotionally handicapped
Re: Well I'm doing:
« Reply #2 on: December 28, 2009, 07:38:52 am »
Code: (pascal) [Select]
DrawText(ID,'Kills: ' +nickName_Kills[ID],GOOD);(255,0,0),0.5,48,260);  ^looks wrong, unless something changed while i was away

try something more along the lines of
Code: (pascal) [Select]
DrawText(ID,'Kills: ' +nickName_Kills[ID],GOOD,RGB(255,0,0),0.5,48,260); 
also, drawing multiple drawtexts at the same time wont work, the last one will overwrite the previous one. You need to merge the lines


Code: (pascal) [Select]
DrawText(ID,'Kills: ' +nickName_Kills[ID] + #13#10 +
          Deaths: ' +nickName_Deaths[ID] + #13#10 +
          SelfKills: '+nickName_SelfKills[ID],GOOD,RGB(255,0,0),0.5,48,260); 

where #13#10 is a newline



edit: if nickName_Kills is an array of integer (which probably is the case), you'll need to do some IntToStr() on it too
« Last Edit: December 28, 2009, 08:39:20 am by dnmr »

Offline dominikkk26

  • Camper
  • ***
  • Posts: 404
    • PMGsite
Re: Well I'm doing:
« Reply #3 on: December 28, 2009, 10:00:57 am »
I want to do something like this:

Offline Silnikos

  • Soldier
  • **
  • Posts: 129
Re: Well I'm doing:
« Reply #4 on: December 28, 2009, 03:25:42 pm »
I want to do something like this:
Code: [Select]
DrawText(ID,'Kills:' +inttostr(nickName_Kills[ID]) +'  Deaths:' +inttostr(nickName_Deaths[ID]) +' SelfKills:'+inttostr(nickName_SelfKills[ID]),GOOD,RGB(255,0,0),0.5,48,260);   

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: Well I'm doing:
« Reply #5 on: December 28, 2009, 03:48:26 pm »
Please use WriteConsole for that and not DrawText. Please.

Offline dominikkk26

  • Camper
  • ***
  • Posts: 404
    • PMGsite
Re: Well I'm doing:
« Reply #6 on: December 29, 2009, 05:37:07 am »
Code: (pascal) [Select]
//ONPLAYERCOMMAND
function OnPlayerCommand(ID: Byte; Text: string): boolean;
var
inputNick, tempNick, InputPassword, InputPasswordLogin, nick: string;
currentDate: string;
begin
//displays player stats
if (Copy(Text,1,6) = '/stats') then
        begin
if GetPlayerStat(ID, 'Active') = true then
begin
nick := GetPlayerStat(ID,'name');

//check if player already got profile or not
if FileExists('stats/nickreg/'+filterFileName(nick)+'.txt') = true then
  begin
//load player profile
LoadNickname(FilterFilename(GetPlayerStat(ID,'name')),ID);

        DrawText(ID,'Kills:' +inttostr(nickName_Kills[ID]) +'  Deaths:' +inttostr(nickName_Deaths[ID]) +' SelfKills:'+inttostr(nickName_SelfKills[ID]),GOOD,RGB(255,0,0),0.5,48,260);   

//check if player has more then 0 deaths otherwise its divide by zero
if strtoint(nickName_Deaths[ID]) > 0 then
begin
kdKills[ID] := strtoint(nickName_Kills[ID]);
kdDeaths[ID] := strtoint(nickName_Deaths[ID]);
kdRatio[ID] := kdKills[ID] / kdDeaths[ID];
WriteConsole(ID,'K/D Ratio: '+floattostr(roundto(kdRatio[ID],2)),GOOD);
end
end else
begin
WriteConsole(ID,'You do not have a profile!',BAD);
end
end
end