Need a example [+REP]
#1

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,
Reply
#2

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.
Reply
#3

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);
        }
    }
Reply
#4

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.
Reply
#5

Okay it works, thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)