2 Problems with my class selection dialog
#1

Problem 1: If someone doesn't have a high enough score, then they can still select a class, even when I have an "else"

Problem 2: When players pick a class, they get weapons, but when they die, they spawn back with no weapons.

How do I fix this? Please I really need to fix this and fix my gamemode, Iv'e been tryna fix it for so long..

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 80)
            {
                if(response)
                    {

                        if(GetPlayerScore(playerid) >= 0)//Private
                        {

                        SetPlayerSkin(playerid, 287);
                        SendClientMessage(playerid, COLOR_WHITE, "You chose the assault as your class.");
                        SendClientMessage(playerid, COLOR_WHITE, "You can type /switchclass to change your class again.");
                        gPlayerClass[playerid] = ASSAULT_CLASS;
                        PickedClass[playerid] = 1;
                        SetPlayerVirtualWorld(playerid, 0);
                        TogglePlayerControllable(playerid, 1);
                        GivePlayerWeapon(playerid, 24, 200);
                        GivePlayerWeapon(playerid, 31, 500);
                        GivePlayerWeapon(playerid, 17, 5);
                        }
                        }


                if(listitem == 1)//sniper DONE
                    {
                        if(GetPlayerScore(playerid) >= 10)//Private

                        {

                            SetPlayerSkin(playerid, 122);
                            SendClientMessage(playerid, COLOR_WHITE, "You chose the Sniper as your class.");
                            SendClientMessage(playerid, COLOR_WHITE, "You can type /switchclass to change your class again.");
                            gPlayerClass[playerid] = SNIPER_CLASS;
                            PickedClass[playerid] = 1;
                            SetPlayerVirtualWorld(playerid, 0);
                            TogglePlayerControllable(playerid, 1);
                            GivePlayerWeapon(playerid, 23, 500);
                            GivePlayerWeapon(playerid, 34, 100);
                            GivePlayerWeapon(playerid, 29, 200);
                           
                    }
                        else
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "You need to be atleast Private class [/rank to see yours]");
                        TogglePlayerControllable(playerid, 0);
                    }
                }

           
                if(listitem == 2)//pilot DONE
                    {
                            if(GetPlayerScore(playerid) >= 1150)//Lieutenant Colonel

                            {

                            SetPlayerSkin(playerid, 61);
                            SendClientMessage(playerid, COLOR_WHITE, "You chose the Pilot as your class.");
                            SendClientMessage(playerid, COLOR_WHITE, "You can type /switchclass to change your class again.");
                            gPlayerClass[playerid] = AIRMAN_CLASS;
                            PickedClass[playerid] = 1;
                            SetPlayerVirtualWorld(playerid, 0);
                            TogglePlayerControllable(playerid, 1);
                            GivePlayerWeapon(playerid, 22, 50);
                            GivePlayerWeapon(playerid, 29, 500);
                            GivePlayerWeapon(playerid, 16, 5);
                           
                    }
                            else
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "You need to be atleast Lieutenant Colonel class [/rank to see yours]");
                        TogglePlayerControllable(playerid, 0);
                    }
                }
                if(listitem == 3)//Engineer
                    {
                            if(GetPlayerScore(playerid) >= 250)//Sergeant

                            {
                            SetPlayerSkin(playerid, 285);
                            SendClientMessage(playerid, COLOR_WHITE, "You chose the Engineer as your class.");
                            SendClientMessage(playerid, COLOR_WHITE, "You can type /switchclass to change your class again.");
                            gPlayerClass[playerid] = ENGINEER_CLASS;
                            PickedClass[playerid] = 1;
                            SetPlayerVirtualWorld(playerid, 0);
                            TogglePlayerControllable(playerid, 1);
                            GivePlayerWeapon(playerid, 22, 100);
                            GivePlayerWeapon(playerid, 32, 500);
                            GivePlayerWeapon(playerid, 35, 5);
                           
                       
                    }
                            else
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "You need to be atleast Sergeant class [/rank to see yours]");
                        TogglePlayerControllable(playerid, 0);
                    }
                }

                if(listitem == 4)//FlameThrower
                    {
                            if(GetPlayerScore(playerid) >= 400)//CAPTAIN

                    {

                            SetPlayerSkin(playerid, 144);
                            SendClientMessage(playerid, COLOR_WHITE, "You chose the Flamethrower as your class.");
                            SendClientMessage(playerid, COLOR_WHITE, "You can type /switchclass to change your class again.");
                            gPlayerClass[playerid] = FLAMETHROWER_CLASS;
                            PickedClass[playerid] = 1;
                            SetPlayerVirtualWorld(playerid, 0);
                            TogglePlayerControllable(playerid, 1);
                            GivePlayerWeapon(playerid, 24, 200);
                            GivePlayerWeapon(playerid, 30, 200);
                            GivePlayerWeapon(playerid, 37, 200);
                           

                    }
                            else
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "You need to be atleast Captain class [/rank to see yours]");
                        TogglePlayerControllable(playerid, 0);
                    }
                }

                if(listitem == 5)//Medic
                    {
                            if(GetPlayerScore(playerid) >= 0)//Private

                            {

                            SetPlayerSkin(playerid, 274);//medic skin
                            SendClientMessage(playerid, COLOR_WHITE, "You chose the Medic Class as your class. [/heal to heal someone]");
                            SendClientMessage(playerid, COLOR_WHITE, "You can type /switchclass to change your class again.");
                            gPlayerClass[playerid] = MEDIC_CLASS;
                            PickedClass[playerid] = 1;
                            SetPlayerVirtualWorld(playerid, 0);
                            TogglePlayerControllable(playerid, 1);
                            SetPlayerHealth(playerid, 5000000);


                            }
                            }
                return 1;
        }
       
return 1;
}
Reply
#2

put this:

pawn Код:
printf("%d", GetPlayerScore(playerid));
and check in console does it return good var
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)