script help
#1

PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
    new 
string[256];
    new 
playercash;
    new 
victimteam;
    new 
Float:px,Float:py,Float:pz;
    new 
killerteam;
    new 
sName[MAX_PLAYER_NAME];
    
GetPlayerName(killerid,sName,MAX_PLAYER_NAME);
    if(
sName[killerid] == "")
    {
    }
    else
    {
        
format(string,sizeof(string),"{00ccff}» {ffffff}You have been killed by {ff6347}%s{ffffff}.",sName);
    }
    
SendClientMessage(playerid,0xFFFFFFAA,string); 
if i put there if(sName[killerid] == "") it gives me an error ...

what code must be there when sName = "" to do nothing ?
Reply
#2

Don't do that,that doesn't make sense,this is the correct way to check it:
pawn Код:
if(killerid!=INVALID_PLAYER_ID)
and DELETE the sName thingy completely
Reply
#3

thanx :X

but if killerid its = my_name ??
Reply
#4

Why you shouldn't make your strings 256 cells big
Reply
#5

Quote:
Originally Posted by CaTaLinU
Посмотреть сообщение
thanx :X

but if killerid its = my_name ??
killerid is a number. This has nothing to do with names.
Use what Cjgogo suggested.


Offtopic:
@Cjgogo: Hi
Reply
#6

pawn Код:
if(!IsPlayerConnected(killerid) || killerid == INVALID_PLAYER_ID || killerid == playerid)
{
    return 0;
}
//etc.
Reply
#7

You also cannot compare names like that.
You have to use strcmp.

https://sampwiki.blast.hk/wiki/Strcmp
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)