SA-MP Forums Archive
Help with team kill menu - 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: Help with team kill menu (/showthread.php?tid=569075)



Help with team kill menu - nicholasramdhan - 28.03.2015

Basically, what this is, is a team kill menu, ex. if a player on your team kills you, you can choose a list of punishments for them. but, for some reason, it gives the player the menu, but when the player chooses their option, it gives the punishment to the person who got killed, not the person who killed them. I tried everything I could, but now I just can't figure it out. There are no errors or warnings whatsoever.

Code:

Код:
public OnPlayerSelectedMenuRow( playerid, row )
{
    new Float:x, Float:y, Float:z;
    new Menu:current;
    current = GetPlayerMenu( playerid );
    if (current == TKMenu) {
        switch(row)
        {
            case 0: {
                 HideMenuForPlayer( TKMenu, playerid );
                 SendClientMessage( PlayerInfo[ playerid ][ pTheKiller ], COLOR_RED, "***Very kind of this person he doesn't punish you for teamkilling!" );
            }
            case 1: {
                 HideMenuForPlayer( TKMenu, playerid );
                 SetPlayerInterior( PlayerInfo[playerid][ pTheKiller ], 6 );
                 SetPlayerPos( PlayerInfo[playerid][ pTheKiller ], 264.6296, 77.1372, 1001.0390);
                 ResetPlayerWeapons( PlayerInfo[playerid][ pTheKiller ] );
                 SetPlayerColor( PlayerInfo[playerid][ pTheKiller ], COLOR_ORANGE );
		         SendClientMessage( PlayerInfo[playerid][ pTheKiller ], COLOR_RED, "*** You've been jailed for teamkilling!" );
            }
            case 2: {
                 HideMenuForPlayer( TKMenu, playerid );
                 SetPlayerHealth( PlayerInfo[playerid][ pTheKiller ], 0 );
                 SendClientMessage( PlayerInfo[playerid][ pTheKiller ], COLOR_RED, "*** You've been sentenced to death for teamkilling!" );
		    }
            case 3: {
                 HideMenuForPlayer( TKMenu, playerid );
                 GivePlayerMoney( PlayerInfo[playerid][ pTheKiller ], -5000 );
		         SendClientMessage( PlayerInfo[playerid][ pTheKiller ], COLOR_RED, "*** You've been fined $5000 for teamkilling!" );
            }
            case 4: {
                 HideMenuForPlayer( TKMenu, playerid );
                 GetPlayerPos( PlayerInfo[playerid][ pTheKiller ], x, y, z );
                 SetPlayerPos( PlayerInfo[playerid][ pTheKiller ], x, y, z+1000 );
                 SendClientMessage( PlayerInfo[playerid][ pTheKiller ], COLOR_RED, "*** You've been dropped from the sky for teamkilling!" );
            }
            case 5: {
                 HideMenuForPlayer( TKMenu, playerid );
                 GetPlayerPos( PlayerInfo[playerid][ pTheKiller ], x, y, z );
                 CreateExplosion( x, y, z, 10, 10 );
                 SetPlayerHealth( PlayerInfo[playerid][ pTheKiller ], 0 );
                 SendClientMessage( PlayerInfo[playerid][ pTheKiller ], COLOR_RED, "*** You've been blown up for teamkilling!" );
            }
            case 6: {
                 HideMenuForPlayer( TKMenu, playerid );
                 SetPlayerHealth( PlayerInfo[playerid][ pTheKiller ], 30 );
                 SendClientMessage( PlayerInfo[playerid][ pTheKiller ], COLOR_RED, "*** 70 percent of your health is taken away for teamkilling!" );
            }
        }
    }
Код:
    TKMenu = CreateMenu( "TeamKill", 1, 30.0, 170.0, 100.0, 150.0 );
    AddMenuItem( TKMenu, 0, "Let him go" );
    AddMenuItem( TKMenu, 0, "Prison" );
    AddMenuItem( TKMenu, 0, "Death Penalty" );
    AddMenuItem( TKMenu, 0, "$5000 Fine" );
    AddMenuItem( TKMenu, 0, "Drop From The Sky" );
    AddMenuItem( TKMenu, 0, "Blow Up" );
    AddMenuItem( TKMenu, 0, "Take 70% Health" );



Re: Help with team kill menu - Crayder - 28.03.2015

1. Menu's are quite outdated these days, but that has nothing to do with your problem.
2. Show us where you set "PlayerInfo[playerid][pTheKiller]," probably in OnPlayerDeath. (This must be the problem because it is an ID conflict.)

EDIT: 3. Notice in case 6, you are not taking away health, you are setting it. Basically what I'm saying is if the killer's health was initially below 30 you actually help him out.


Re: Help with team kill menu - nicholasramdhan - 28.03.2015

Here's my list of the PlayerInfo's
It's all under OnPlayerConnect btw:

Код:
    OnPlayerConnect_TWS(playerid);
    AllowPlayerTeleport(playerid, 0);
    SetPlayerWantedLevel(playerid, 0);
    PlayerInfo[playerid][ pCheckpoint ]=0;
    PlayerInfo[playerid][ pLogged ]=0;
    PlayerInfo[playerid][ plTMoney ]=0;
    PlayerInfo[playerid][ plSMoney ]=0;
    PlayerInfo[playerid][ pPlayingAGame ]=0;
    PlayerInfo[playerid][ pPlayerVehicles ]=0;
    PlayerInfo[playerid][ pClassID ]=0;
    PlayerInfo[playerid][ pShowPM ]=0;
    PlayerInfo[playerid][ pShowTPM ]=0;
    PlayerInfo[playerid][ pCanUseCommands ]=1;
    PlayerInfo[playerid][ pOnDuty ]=0;
    PlayerInfo[playerid][ pSpawned ]=0;
    PlayerInfo[playerid][ pAdmin ]=0;
    PlayerInfo[playerid][ pChallengingMessage ]=0;
    PlayerInfo[playerid][ pBike ]=0;
    PlayerInfo[playerid][ pTheKiller ]=0;
    PlayerInfo[playerid][ pMuted ]=0;
    PlayerInfo[playerid][ pKills ]=0;
    PlayerInfo[playerid][ pDeaths ]=0;



Re: Help with team kill menu - Crayder - 28.03.2015

NO, not that. Like I said before, it will probably be in OnPlayerDeath.


Re: Help with team kill menu - nicholasramdhan - 28.03.2015

Код:
    else //Team Killer!
    {
        if (PlayerInfo[ killerid ][ pPlayingAGame ]==0 && playerid != TheClown) {
            ShowMenuForPlayer(TKMenu, playerid);
		    SendClientMessage( killerid, COLOR_RED, "* No teamkilling! Be prepared for the worst." );
		    if (IsPlayerConnected(killerid)) return PlayerInfo[ killerid ][ pTheKiller ] = killerid;
        }
   	}

   	SetPlayerArmour(playerid, 0);
   	PlayerInfo[playerid][ pPlayingAGame ]=0;

	return 1;
}
This? It's under OnPlayerDeath.


Re: Help with team kill menu - Crayder - 28.03.2015

Quote:
Originally Posted by nicholasramdhan
Посмотреть сообщение
Код:
    else //Team Killer!
    {
        if (PlayerInfo[ killerid ][ pPlayingAGame ]==0 && playerid != TheClown) {
            ShowMenuForPlayer(TKMenu, playerid);
		    SendClientMessage( killerid, COLOR_RED, "* No teamkilling! Be prepared for the worst." );
		    if (IsPlayerConnected(killerid)) return PlayerInfo[ killerid ][ pTheKiller ] = killerid;
        }
   	}

   	SetPlayerArmour(playerid, 0);
   	PlayerInfo[playerid][ pPlayingAGame ]=0;

	return 1;
}
This? It's under OnPlayerDeath.
if (IsPlayerConnected(killerid)) PlayerInfo[ playerid ][ pTheKiller ] = killerid;


Re: Help with team kill menu - nicholasramdhan - 28.03.2015

Thanks so much. +rep for you.