K/D -
tarez - 07.09.2011
+1 to kills and deaths everytime someone kills/dies..
pawn Код:
PlayerInfo[playerid][pKills]
PlayerInfo[playerid][pDeaths]
If you can, explain how to do it so I can learn, if not just type it up and it'll still help me.. thanks
Re: K/D -
Scenario - 08.09.2011
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
PlayerInfo[killerid][pKills]++;
PlayerInfo[playerid][pDeaths]++;
}
4 char.
Re: K/D -
tarez - 08.09.2011
Facepalm.. simple
Anyways, I have this second little problem now..
pawn Код:
COMMAND:stats(playerid, params[])
{
new kills;
new deaths;
deaths = PlayerInfo[playerid][pDeaths]
kills = PlayerInfo[playerid][pKills]
format(String, sizeof(String), "Kills: %d || Deaths: %d", kills, deaths);
SendClientMessage(playerid, COLOR_REDD, String);
return 1;
}
Errors
Код:
C:\Users\Kevin.Sylvie\Desktop\DM\gamemodes\DM.pwn(133) : error 001: expected token: ";", but found "-identifier-"
C:\Users\Kevin.Sylvie\Desktop\DM\gamemodes\DM.pwn(134) : error 001: expected token: ";", but found "-identifier-"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
2 Errors.
Re: K/D -
=WoR=G4M3Ov3r - 08.09.2011
PHP код:
COMMAND:stats(playerid, params[])
{
new kills;
new deaths;
deaths = PlayerInfo[playerid][pDeaths];
kills = PlayerInfo[playerid][pKills];
format(String, sizeof(String), "Kills: %d || Deaths: %d", kills, deaths);
SendClientMessage(playerid, COLOR_REDD, String);
return 1;
}
Re: K/D -
Kush - 08.09.2011
Quote:
Originally Posted by G4M3Ov3r
PHP код:
COMMAND:stats(playerid, params[])
{
new kills;
new deaths;
deaths = PlayerInfo[playerid][pDeaths];
kills = PlayerInfo[playerid][pKills];
format(String, sizeof(String), "Kills: %d || Deaths: %d", kills, deaths);
SendClientMessage(playerid, COLOR_REDD, String);
return 1;
}
|
I'm not understanding. Why would you re-declare a variable?
PHP код:
CMD:stats(playerid, params[])
{
new string[128];
format(string, sizeof(string), "Kills: %d || Deaths: %d", PlayerInfo[playerid][pKills], PlayerInfo[playerid][pDeaths]);
SendClientMessage(playerid, COLOR_REDD, string);
return 1;
}
Wouldn't that be simpler?
Re: K/D -
=WoR=G4M3Ov3r - 08.09.2011
Quote:
Originally Posted by Kush
I'm not understanding. Why would you re-declare a variable?
PHP код:
CMD:stats(playerid, params[])
{
new string[128];
format(string, sizeof(string), "Kills: %d || Deaths: %d", PlayerInfo[playerid][pKills], PlayerInfo[playerid][pDeaths]);
SendClientMessage(playerid, COLOR_REDD, string);
return 1;
}
Wouldn't that be simpler?
|
Mhm, i didn't declare anything, I just fixed the errors your Code, and Las Venturas's are easier, and much simpler tho.
Re: K/D -
Kush - 08.09.2011
Quote:
Originally Posted by G4M3Ov3r
Mhm, i didn't declare anything, I just fixed the errors your Code, and Las Venturas's are easier, and much simpler tho.
|
It's bad habits to declare something globally in which your only going to reference it once.
Re: K/D -
Scenario - 08.09.2011
Quote:
Originally Posted by tarez
pawn Код:
COMMAND:stats(playerid, params[]) { new kills; new deaths; deaths = PlayerInfo[playerid][pDeaths] kills = PlayerInfo[playerid][pKills] format(String, sizeof(String), "Kills: %d || Deaths: %d", kills, deaths); SendClientMessage(playerid, COLOR_REDD, String); return 1; }
|
That isn't going to accomplish this:
Quote:
Originally Posted by tarez
+1 to kills and deaths everytime someone kills/dies..
|
Final code:
pawn Код:
CMD:stats(playerid, params[])
{
PlayerInfo[killerid][pKills]++;
PlayerInfo[playerid][pDeaths]++;
printf("Kills: %d || Deaths: %d", PlayerInfo[playerid][pKills], PlayerInfo[playerid][pDeaths]);
return 1;
}
Re: K/D -
Kush - 08.09.2011
Quote:
Originally Posted by RealCop228
That isn't going to accomplish this:
Final code:
pawn Код:
CMD:stats(playerid, params[]) { PlayerInfo[killerid][pKills]++; PlayerInfo[playerid][pDeaths]++; printf("Kills: %d || Deaths: %d", PlayerInfo[playerid][pKills], PlayerInfo[playerid][pDeaths]); return 1; }
|
Wait, this makes no sense?
Re: K/D -
=WoR=Varth - 08.09.2011
Quote:
Originally Posted by RealCop228
pawn Код:
public OnPlayerDeath(playerid, killerid, reason) { PlayerInfo[killerid][pKills]++; PlayerInfo[playerid][pDeaths]++; }
4 char.
|
Perhaps I should quote this:
Quote:
Important Note: Contrary to popular belief you do not need the check to see if killerid is INVALID_PLAYER_ID before sending the message as if it is you just send INVALID_PLAYER_ID anyway, making the entire check pointless and redundant. However you will require this check before doing other things such as awarding money.
|