SA-MP Forums Archive
Need a example [+REP] - 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: Need a example [+REP] (/showthread.php?tid=310710)



Need a example [+REP] - smokeweed - 13.01.2012

Can someone give me an example, for a dialog when you spawn and then can choose from different classes. For example, Soldier, Sniper, Engineer etc. For Sniper you must have rank 2 and for Engineer you must have rank 3.

Thanks,


Re: Need a example [+REP] - Mean - 13.01.2012

ShowPlayerDialog for more info.
pawn Код:
#define DIALOG_CLASS 3487
public OnPlayerSpawn(playerid) {
    ShowPlayerDialog(playerid, DIALOG_CLASS, DIALOG_STYLE_LIST, "Choose your class", "Class 1\nClass 2\nClass 3", "Choose", "");
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
    if(dialogid == DIALOG_CLASS) {
        if(!response) // if player presses ESC re-show the dialog
            return ShowPlayerDialog(playerid, DIALOG_CLASS, DIALOG_STYLE_LIST, "Choose your class", "Class 1\nClass 2\nClass 3", "Choose", "");
        switch(listitem) {
            case 0: { // CLASS 1
                // stuff for class 1 (such as weapons, abilities, etc.)
            }
            case 1: { // CLASS 2
                // stuff for class 2
            }
            case 2: { // CLASS 3
                // stuff for class 3
            }
            // etc
        }
    }
    return 0;
}
Of course, you can add more classes, make sure to modify the ShowPlayerDialog in the if(!response) and under OnPlayerSpawn.


Re: Need a example [+REP] - smokeweed - 13.01.2012

Wow thanks!! How to add the required ranks? I mean, check if a player haves rank 5 to choose the Pilot class. I have already fixed the rank system
Код:
{
    if ( GetPlayerScore(playerid) >= 50 ) {
        if( rank[playerid] < 1 ) {
            PlayerPlaySound(playerid, 1150, 0, 0, 0);
            SendClientMessage(playerid, COLOR_CON_GREEN,"You Got Promoted!");
            SendClientMessage(playerid, COLOR_CON_GREEN, "*You are a Private!");
            rank[playerid] = 1;
            SetPlayerWantedLevel(playerid, rank[playerid]);
            GivePlayerMoney(playerid, 5000);
        }
    }



Re: Need a example [+REP] - Mean - 13.01.2012

pawn Код:
switch(listitem) {
    case 0: { // CLASS 1
        if(rank[playerid] >= 5) { // If the player is rank 5 or above
            // stuff for pilot
        }
    }
    case 1: { // CLASS 2
        // stuff for class 2
    }
    case 2: { // CLASS 3
        // stuff for class 3
    }
    // etc
}
etc.


Re: Need a example [+REP] - smokeweed - 13.01.2012

Okay it works, thanks