script 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: script help (
/showthread.php?tid=372037)
script help -
CaTaLinU - 25.08.2012
PHP код:
public OnPlayerDeath(playerid, killerid, reason)
{
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 ?
Re: script help -
Cjgogo - 25.08.2012
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
Re: script help -
CaTaLinU - 25.08.2012
thanx :X
but if killerid its = my_name ??
Re: script help -
Riddick94 - 25.08.2012
Why you shouldn't make your strings 256 cells big
Re: script help -
ikkentim - 25.08.2012
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
Re: script help -
clarencecuzz - 25.08.2012
pawn Код:
if(!IsPlayerConnected(killerid) || killerid == INVALID_PLAYER_ID || killerid == playerid)
{
return 0;
}
//etc.
Re: script help -
shitbird - 25.08.2012
You also cannot compare names like that.
You have to use strcmp.
https://sampwiki.blast.hk/wiki/Strcmp