SA-MP Forums Archive
Menu Punishment for TK - 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: Menu Punishment for TK (/showthread.php?tid=279246)



Menu Punishment for TK - Tigerbeast11 - 26.08.2011

I wanted to create a Team Kill Punishment menu and the person who got killed would choose the punishment...
pawn Code:
if(Team[killerid] == Team[playerid])
{
ShowMenuForPlayer(playerid,punish);
}
But how would I punish the team killer? What would I put under onplayerselectmenurow?


Re: Menu Punishment for TK - Bakr - 26.08.2011

Follow the guide on this page: https://sampwiki.blast.hk/wiki/OnPlayerSelectedMenuRow . It gives you everything you need to know how to create and use a dialog.


Re: Menu Punishment for TK - Tigerbeast11 - 26.08.2011

Quote:
Originally Posted by Bakr
View Post
Follow the guide on this page: https://sampwiki.blast.hk/wiki/OnPlayerSelectedMenuRow . It gives you everything you need to know how to create and use a dialog.
But the problem is, OnPlayerSelectedMenuRow doesn't have a killerid parameter so how would I punish the team killer?


Re: Menu Punishment for TK - Bakr - 26.08.2011

Store the ID of the killer in a per-player variable, and access it inside the callback when necessary
pawn Code:
// global variable
new g_PlayerKiller[ MAX_PLAYERS ] = { INVALID_PLAYER_ID, ... };

//OnPlayerDeath
if( Team[ killerid ] == Team[ playerid ] )
{
   g_PlayerKiller[ playerid ] = killerid;
   // rest of code
}

//OnPlayerSelectedMenuRow
SetPlayerHealth( g_PlayerKiller[ playerid ], 0.00 ); // example punishment, killing the player
g_PlayerKiller[ playerid ] = INVALID_PLAYER_ID;



Re: Menu Punishment for TK - Tigerbeast11 - 27.08.2011

Quote:
Originally Posted by Bakr
View Post
Store the ID of the killer in a per-player variable, and access it inside the callback when necessary
pawn Code:
// global variable
new g_PlayerKiller[ MAX_PLAYERS ] = { INVALID_PLAYER_ID, ... };

//OnPlayerDeath
if( Team[ killerid ] == Team[ playerid ] )
{
   g_PlayerKiller[ playerid ] = killerid;
   // rest of code
}

//OnPlayerSelectedMenuRow
SetPlayerHealth( g_PlayerKiller[ playerid ], 0.00 ); // example punishment, killing the player
g_PlayerKiller[ playerid ] = INVALID_PLAYER_ID;
OK, thanks. But what would I put after the three "...":
pawn Code:
{ INVALID_PLAYER_ID, ... };