PDA

View Full Version : Command


lsreskjn
14/02/2014, 06:26 PM
Hey, I have a command for /kill that show a message that the player committed a suaside ...I olso have OnPlayerDeath that if someone kill someone.. it will show in chat...but when you type /kill it shows the message that player xx killed xxx...is it possible to do it so if player type /kill it will not show that message?

CODES

if(strcmp("/kill", cmdtext) == 0)
{
SetPlayerHealth(playerid,-1); // zabije hraca
SendClientMessage(playerid, 0x800080FF, "[ Server ] Spáchal si samovraždu.");
new string[130],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
format(string,sizeof string,"{C0C0C0}[ Samovražda ] Hrác {FF0000}%s{C0C0C0} spáchal samovraždu.",name);
SendClientMessageToAll(0xFFFFFFAA,string);
printf("Player %s used command %s",Jmeno(playerid), cmdtext);
pDeaths[playerid]-=1;
return 1;
}


new playername[24], killername[24];
GetPlayerName(playerid, playername, sizeof(playername));
GetPlayerName(killerid, killername, sizeof(killername));
PlayAudioStreamForPlayer(playerid, "http://k007.kiwi6.com/hotlink/ha4beyib1d/laugh_dp.wav");
PlayAudioStreamForPlayer(killerid, "http://k007.kiwi6.com/hotlink/sx65ro...amestartup.mp3");
new string[128];
format(string,sizeof string,"{C0C0C0}[ KILL-LIST ] Hrác %s zabil %s.",killername, playername);
SendClientMessageToAll(0xFFFFFFAA,string);

CuervO
14/02/2014, 06:30 PM
pDeaths[playerid]-=1;

Shouldn't that be ++ or += 1; ?

Set a variable at where the player suicides to 1, then at OnPlayerDeath check if that variable is 1, if so, set the killerid to INVALID_PLAYER_ID and do not send the message.

lsreskjn
14/02/2014, 06:32 PM
Im not sure, im new to pawno and i ony know the basic stuff so i cant script it

CuervO
14/02/2014, 06:35 PM
What I said to do is pretty basic, though.

You only need to know very very basic operatives, anyways...


if(strcmp("/kill", cmdtext) == 0)
{
SetPlayerHealth(playerid,-1); // zabije hraca
SendClientMessage(playerid, 0x800080FF, "[ Server ] Spáchal si samovraždu.");
new string[130],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
format(string,sizeof string,"{C0C0C0}[ Samovražda ] Hrác {FF0000}%s{C0C0C0} spáchal samovraždu.",name);
SendClientMessageToAll(0xFFFFFFAA,string);
printf("Player %s used command %s",Jmeno(playerid), cmdtext);
pDeaths[playerid] ++;
SetPVarInt(playerid,"Suicided",1); // set the variable
return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
new playername[24], killername[24];
if(GetPVarInt(playerid,"Suicided") == 0) //check if player suicided
{
GetPlayerName(playerid, playername, sizeof(playername));
GetPlayerName(killerid, killername, sizeof(killername));
PlayAudioStreamForPlayer(playerid, "http://k007.kiwi6.com/hotlink/ha4beyib1d/laugh_dp.wav");
PlayAudioStreamForPlayer(killerid, "http://k007.kiwi6.com/hotlink/sx65ro...amestartup.mp3");
new string[128];
format(string,sizeof string,"{C0C0C0}[ KILL-LIST ] Hrác %s zabil %s.",killername, playername);
SendClientMessageToAll(0xFFFFFFAA,string);
}
SetPVarInt(playerid,"Suicided",0); // reset the variable
return 1;
}

terrow
14/02/2014, 06:38 PM
Yes it possible you need to make a variable at first your GM

new gPlayerUsedKill[ MAX_PLAYERS ];

I don't know to use STRCMP i will show you in ZCMD ..

CMD:kill( playerid, params[ ] )
{
SetPlayerHealth(playerid,-1); // zabije hraca
SendClientMessage(playerid, 0x800080FF, "[ Server ] Spáchal si samovraždu.");
printf("Player %s used command %s",Jmeno(playerid), cmdtext);
pDeaths[playerid]-=1;
gPlayerUsedKill[ playerid ] = 1; // Here is the variable //
return ( 1 );
}

and on player death

if ( gPlayerUsedKill[ playerid ] == 1 )
{
new string[130],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
format(string,sizeof string,"{C0C0C0}[ Samovražda ] Hrác {FF0000}%s{C0C0C0} spáchal samovraždu.",name);
SendClientMessageToAll(0xFFFFFFAA,string);
gPlayerUsedKill[ playerid ] = 0;
}


I hope this will be works! :)