SA-MP Forums Archive
OnPlayerDeath Help! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: OnPlayerDeath Help! (/showthread.php?tid=430230)



OnPlayerDeath Help! - Areax - 13.04.2013

Hello!

Is here anything wrong?

Code:

PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
    
SendDeathMessage(killeridplayeridreason); 
    if(
killerid != INVALID_PLAYER_ID
    {
        
        
SetPlayerScore(killerid, +1);
        
PLAYER_CASH[killerid] += 100;
        
GivePlayerMoney(killerid100);
    }
    
PLAYER_DEATHS[playerid]++;
    
PLAYER_CASH[playerid] -= 100;
    
PLAYER_KILLS[killerid]++;
    
PLAYER_SCORE[killerid]++;
    return 
1;

Thanks for your help


Re: OnPlayerDeath Help! - [XST]O_x - 13.04.2013

Yeah, you're setting the killer's score to 1. The '+' doesn't make any difference, it only shows that it's a positive number.
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    SendDeathMessage(killerid, playerid, reason);  

    if(killerid != INVALID_PLAYER_ID)  
    {
         
        SetPlayerScore(killerid, GetPlayerScore(killerid)+1);

        PLAYER_CASH[killerid] += 100;
        GivePlayerMoney(killerid, 100);
    }
    PLAYER_DEATHS[playerid]++;
    PLAYER_CASH[playerid] -= 100;
    PLAYER_KILLS[killerid]++;
    PLAYER_SCORE[killerid]++;
    return 1;
}



Re: OnPlayerDeath Help! - [ABK]Antonio - 13.04.2013

You're also not setting the playerid's cash like you are killerids. Not sure if intended like that or not


Re: OnPlayerDeath Help! - Areax - 13.04.2013

I get this errors:

Quote:

C:\Users\tadej\Desktop\SA-MP Server\gamemodes\New.pwn(283) : error 028: invalid subscript (not an array or too many subscripts): "PLAYER_MONEY"
C:\Users\tadej\Desktop\SA-MP Server\gamemodes\New.pwn(283) : warning 215: expression has no effect
C:\Users\tadej\Desktop\SA-MP Server\gamemodes\New.pwn(283) : error 001: expected token: ";", but found "]"
C:\Users\tadej\Desktop\SA-MP Server\gamemodes\New.pwn(283) : error 029: invalid expression, assumed zero
C:\Users\tadej\Desktop\SA-MP Server\gamemodes\New.pwn(283) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.




Re: OnPlayerDeath Help! - [ABK]Antonio - 13.04.2013

Quote:
Originally Posted by Areax
Посмотреть сообщение
I get this errors:
I figured as much

Can you show us the declarations of those arrays?


Re: OnPlayerDeath Help! - Areax - 13.04.2013

PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
    
SendDeathMessage(killeridplayeridreason);
    if(
killerid != INVALID_PLAYER_ID)
    {
        
SetPlayerScore(killeridGetPlayerScore(killerid)+1);
        
GivePlayerMoney(killerid100);
    }
    
PLAYER_DEATHS[playerid]++;
    
PLAYER_MONEY[playerid] -= 100;
    
PLAYER_KILLS[killerid]++;
    
PLAYER_SCORE[killerid]++;
    
PLAYER_MONEY[killerid]++= 100;
    return 
1;




Re: OnPlayerDeath Help! - [XST]O_x - 13.04.2013

Quote:
Originally Posted by Areax
Посмотреть сообщение
PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
    
SendDeathMessage(killeridplayeridreason);
    if(
killerid != INVALID_PLAYER_ID)
    {
        
SetPlayerScore(killeridGetPlayerScore(killerid)+1);
        
GivePlayerMoney(killerid100);
    }
    
PLAYER_DEATHS[playerid]++;
    
PLAYER_MONEY[playerid] -= 100;
    
PLAYER_KILLS[killerid]++;
    
PLAYER_SCORE[killerid]++;
    
PLAYER_MONEY[killerid]++= 100;
    return 
1;

That's the implementation of the variables, not their declaration.
He means, show us where you define the variables (new PLAYER_DEATHS...)


Re: OnPlayerDeath Help! - zxc1 - 13.04.2013

pawn Код:
PLAYER_MONEY[killerid]+= 100;



Re: OnPlayerDeath Help! - Areax - 13.04.2013

Quote:
Originally Posted by [XST]O_x
Посмотреть сообщение
That's the implementation of the variables, not their declaration.
He means, show us where you define the variables (new PLAYER_DEATHS...)
If you mean enums...

PHP код:
enum PLAYER_MAIN
{
     
PLAYER_NAME[MAX_PLAYER_NAME],
     
PLAYER_IP[16],
     
PLAYER_REGGED,
     
PLAYER_PASS,
     
PLAYER_LEVEL,
     
PLAYER_MONEY,
     
PLAYER_SCORE,
     
PLAYER_MUTED,
     
PLAYER_MUTE_TIME,
     
PLAYER_KILLS,
     
PLAYER_DEATHS 



Re: OnPlayerDeath Help! - [XST]O_x - 13.04.2013

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    SendDeathMessage(killerid, playerid, reason);

    if(killerid != INVALID_PLAYER_ID)
    {

        SetPlayerScore(killerid, GetPlayerScore(killerid)+1);

        GivePlayerMoney(killerid, 100);
    }
    gPlayerInfo[playerid][PLAYER_DEATHS]++;
    gPlayerInfo[playerid][PLAYER_MONEY] -= 100;
    gPlayerInfo[killerid][PLAYER_KILLS]++;
    gPlayerInfo[killerid][PLAYER_SCORE]++;
    gPlayerInfo[killerid][PLAYER_MONEY]+= 100;
    return 1;
}