#1

+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
Reply
#2

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
   PlayerInfo[killerid][pKills]++;
   PlayerInfo[playerid][pDeaths]++;
}
4 char.
Reply
#3

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.
Reply
#4

PHP код:
COMMAND:stats(playeridparams[])
{
    new 
kills;
    new 
deaths;
    
deaths PlayerInfo[playerid][pDeaths];
    
kills PlayerInfo[playerid][pKills];
    
format(Stringsizeof(String), "Kills: %d || Deaths: %d"killsdeaths);
    
SendClientMessage(playeridCOLOR_REDDString);
    return 
1;

Reply
#5

Quote:
Originally Posted by G4M3Ov3r
Посмотреть сообщение
PHP код:
COMMAND:stats(playeridparams[])
{
    new 
kills;
    new 
deaths;
    
deaths PlayerInfo[playerid][pDeaths];
    
kills PlayerInfo[playerid][pKills];
    
format(Stringsizeof(String), "Kills: %d || Deaths: %d"killsdeaths);
    
SendClientMessage(playeridCOLOR_REDDString);
    return 
1;

I'm not understanding. Why would you re-declare a variable?

PHP код:
CMD:stats(playeridparams[])
{
    new 
string[128];
    
format(stringsizeof(string), "Kills: %d || Deaths: %d"PlayerInfo[playerid][pKills], PlayerInfo[playerid][pDeaths]);
    
SendClientMessage(playeridCOLOR_REDDstring);
    return 
1;

Wouldn't that be simpler?
Reply
#6

Quote:
Originally Posted by Kush
Посмотреть сообщение
I'm not understanding. Why would you re-declare a variable?

PHP код:
CMD:stats(playeridparams[])
{
    new 
string[128];
    
format(stringsizeof(string), "Kills: %d || Deaths: %d"PlayerInfo[playerid][pKills], PlayerInfo[playerid][pDeaths]);
    
SendClientMessage(playeridCOLOR_REDDstring);
    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.
Reply
#7

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.
Reply
#8

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;
}
Reply
#9

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?
Reply
#10

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.

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)