Got confused with a SCRIPT!
#1

Hello SA-MP World!
My name is Ady .
And i've got confused about a function
Let me explain.

A player x is in gang y , when player x got killed by player z which is in gang y . I want to make a dialog to show them
1.Kill member
2.Reset Player Weapons
3.Free [don't make anything]

So i will show you the function

pawn Код:
if ( Users[ killerid ][ gang ] == Users[ playerid ][ gang ] )
                FormatMSG( playerid, COLOR_ULTRARED, "!! ATENTION !!: %s , killed you and he is with you in gang !", PlayerName( killerid ) );

This is the originally now what's i did

            if ( Users[ killerid ][ gang ] == Users[ playerid ][ gang ] )
                ShowPlayerDialog(playerid, DIALOG_GANGKILLED, DIALOG_STYLE_LIST, "You'
ve got killed by a gang member", "Kill member\nReset Player Weapons\nFree", "Select", "Leave");

// Now that's my problem, here i'm blocked .

OnDialogResponse(bla bla)
{

    case DIALOG_GANGKILLED:
    {
         switch( listitem )
         {
               case 0: // here's the problem how i can make to kill the player z who killed player x ? I'm think it's using foreach but i don't know ... please help me ! :)
I will hope you to help me !

REGARDS~~
Reply
#2

You need to pass the killerid to OnDialogResponse

Just save it in a global array in OnPlayerDeath and recall it in OnDialogResponse
Reply
#3

Hmmm like making a new variable like : new GangKilled[ MAX_PLAYERS ];

And when player x got killed by player y

GangKilled[killerid] = 1;

Something like this ?
Reply
#4

More like
pawn Код:
new // Can be used for different dialogs and other things
    gCarry[MAX_PLAYERS] // Just a variable to carry data across functions
;
pawn Код:
if ( Users[ killerid ][ gang ] == Users[ playerid ][ gang ] ) {
    ShowPlayerDialog(playerid, DIALOG_GANGKILLED, DIALOG_STYLE_LIST, "You've got killed by a gang member", "Kill member\nReset Player Weapons\nFree", "Select", "Leave");

    gCarry[playerid] = killerid;
}
pawn Код:
//
    case DIALOG_GANGKILLED: {
        switch( listitem ) {
                case 0: SetPlayerHealth(gCarry[playerid], 0.0);
                case 1: ResetPlayerWeapons(gCarry[playerid]);
                case 2: SendClientMessage(gCarry[playerid], -1, "Blabla spared your live!");
        }
    }
Reply
#5

Lol thanks , i hope will works +REP!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)