SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 26/07/2016, 06:13 AM   #1
Ankon
Little Clucker
 
Join Date: May 2015
Posts: 37
Reputation: 0
Question Class Selection problems!

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..
__________________
Ankon is offline   Reply With Quote
Old 26/07/2016, 06:22 AM   #2
itsCody
Gangsta
 
Join Date: Nov 2012
Location: Canada
Posts: 519
Reputation: 45
Default Re: Class Selection problems!

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;

itsCody is offline   Reply With Quote
Old 26/07/2016, 06:27 AM   #3
Ankon
Little Clucker
 
Join Date: May 2015
Posts: 37
Reputation: 0
Default Re: Class Selection problems!

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?
__________________
Ankon is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to make a class selection screen with class system hardiksingh5 Scripting Help 7 24/03/2015 06:54 AM
2 Problems with my class selection dialog Eminem 2ka9 Scripting Help 1 26/10/2012 10:52 PM
Use a Filterscripts Class Selection Instead of Gamemode Class Selection Eminem 2ka9 Scripting Help 12 04/08/2012 05:00 AM
Problems with camera on class selection laserhel50 Help Archive 3 17/12/2009 01:16 PM


All times are GMT. The time now is 12:06 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.