Class Selection problems!
#1

Hey friends... yep it is me again..
On a hatrick....Three help posts at the same time....
Will need your help again.. I was creating a class selection system here and there is a weird problem..

Here is the code described...

new showclass;
new class_assault;
new class_sniper;

three things defined... showclass(if set to 1, will not show the next time and if 0 will show when spawning)
class_assault(assault class to give weapons)
class_sniper(the same)


Under OnPlayerConnect I set all of them to 0...

Under OnPlayerSpawn

if(showclass == 0)
{
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Class Selction", "Assault-Rank 1\nSniper-Rank 2", "Choose", "");
}
else if(showclass == 1 && class_assault == 1)
{
GivePlayerWeapon(playerid, 24, 100);
GivePlayerWeapon(playerid, 27, 76);
GivePlayerWeapon(playerid, 16, 3);
GivePlayerWeapon(playerid, 31, 300);
}
else if(showclass == 1 && class_sniper == 1)
{
GivePlayerWeapon(playerid, 4, 0);
GivePlayerWeapon(playerid, 23, 60);
GivePlayerWeapon(playerid, 17, 3);
GivePlayerWeapon(playerid, 34, 200);
}


I did it like this because I want players to choose class only the first time they connect...other times it just goes with the one they selected before..
And finally

Under OnDialogResponse(remember I only have one dialog...for others I used different functions like stocks..)

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(response)
{
switch(listitem)
{
case 0:
{
showclass = 1;
class_assault = 1;
}
case 1:
{
showclass = 1;
class_sniper = 1;
}
}
}
return 1;
}


Now the problem..
When the player spawns he doesn't get the weapons...
Please help..
Reply
#2

You're not giving him any weapons under OnDialogResponse when they first choose.
Also, this system should be per-player to prevent issues.

PHP Code:
new showclass[MAX_PLAYERS], class_assault[MAX_PLAYERS], class_sniper[MAX_PLAYERS];
public 
OnPlayerConnect(playerid)
{
    
showclass[playerid] = 0;
    
class_assault[playerid] = 0;
    
class_sniper[playerid] = 0;
    return 
1;
}
public 
OnPlayerSpawn(playerid)
{
    if(
showclass[playerid] == 0)
    {
        
ShowPlayerDialog(playerid2DIALOG_STYLE_LIST"Class Selction""Assault-Rank 1\nSniper-Rank 2""Choose""");
    }
    else if(
showclass[playerid] == && class_assault[playerid] == 1)
    {
        
GivePlayerWeapon(playerid24100);
        
GivePlayerWeapon(playerid2776);
        
GivePlayerWeapon(playerid163);
        
GivePlayerWeapon(playerid31300);
    }
    else if(
showclass[playerid] == && class_sniper[playerid] == 1)
    {
        
GivePlayerWeapon(playerid40);
        
GivePlayerWeapon(playerid2360);
        
GivePlayerWeapon(playerid173);
        
GivePlayerWeapon(playerid34200);
    }
    return 
1;
}
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    if(
response)
    {
        switch(
listitem)
        {
            case 
0:
            {
                
GivePlayerWeapon(playerid24100);
                
GivePlayerWeapon(playerid2776);
                
GivePlayerWeapon(playerid163);
                
GivePlayerWeapon(playerid31300);
                
showclass[playerid] = 1;
                
class_assault[playerid] = 1;
            }
            case 
1:
            {
                
GivePlayerWeapon(playerid40);
                
GivePlayerWeapon(playerid2360);
                
GivePlayerWeapon(playerid173);
                
GivePlayerWeapon(playerid34200);
                
showclass[playerid] = 1;
                
class_sniper[playerid] = 1;
            }
        }
    }
    return 
1;

Reply
#3

hi friend thanks for that fix but I want the weapons to be repeated..
Only the first time a player connects the server would get a chance to select the class...rest of the time they will just go on with what they selected...does your script do that?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)