Another "OnDialogResponse" problem
#1

Ugh, when i add "
pawn Код:
Class_Chosen{ playerid } = false;
, i get this error:
.....\test.pwn(493) : error 029: invalid expression, assumed zero
I've tried adding brackets, changing the location etc.. but no luck :[
If you can fix it, then please help me..
Here's the script:
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_CLASS1:
        {
            if(response)
            {
                switch(listitem)
                {
                    case 0:
                    {
                        if(GetPlayerScore(playerid) < 150) SendClientMessage(playerid, COLOR_RED, "You need to  have 150 score to use the Sniper class!");
                        Class_Chosen{ playerid } = false;
                        else //Line 493, error here.
                        SendClientMessage(playerid, COLOR_GREEN, "Sniper class chosen!");
                        SpawnPlayer(playerid);
                        ResetPlayerWeapons(playerid);
                        SetPlayerSkin(playerid, 285);
                        GivePlayerWeapon(playerid, 4, 1);
                        GivePlayerWeapon(playerid, 23, 500);
                        GivePlayerWeapon(playerid, 25, 150);
                        GivePlayerWeapon(playerid, 29, 850);
                        GivePlayerWeapon(playerid, 34, 500);
                        SetPlayerArmour(playerid, 99.0);
                        Class_Chosen{ playerid } = true;
                    }
                    case 1:
                    {
                        if(GetPlayerScore(playerid) < 150) return SendClientMessage(playerid, COLOR_RED, "You need to have 150 score to use the Medic class!");
                        Class_Chosen{ playerid } = false;
                        else //Line 510, error here.
                        SendClientMessage(playerid, COLOR_GREEN, "Medic class chosen!");
                        SendClientMessage(playerid, COLOR_GREEN, "You can use /heal to heal your teammates!");
                        SpawnPlayer(playerid);
                        ResetPlayerWeapons(playerid);
                        SetPlayerSkin(playerid, 275);
                        GivePlayerWeapon(playerid, 16, 1);
                        GivePlayerWeapon(playerid, 22, 257);
                        GivePlayerWeapon(playerid, 25, 350);
                        GivePlayerWeapon(playerid, 30, 550);
                        SetPlayerArmour(playerid, 99);
                        Class_Chosen{ playerid } = true;
                    }
                    case 2:
                    {
                        SendClientMessage(playerid, COLOR_GREEN, "Assault class chosen!");
                        SpawnPlayer(playerid);
                        ResetPlayerWeapons(playerid);
                        SetPlayerSkin(playerid, 287);
                        GivePlayerWeapon(playerid, 16, 3);
                        GivePlayerWeapon(playerid, 24, 320);
                        GivePlayerWeapon(playerid, 27, 180);
                        GivePlayerWeapon(playerid, 29, 500);
                        GivePlayerWeapon(playerid, 31, 500);
                        GivePlayerWeapon(playerid, 35, 1);
                        SetPlayerArmour(playerid, 99);
                        Class_Chosen{ playerid } = true;
                    }
                    case 3:
                    {
                        if(GetPlayerScore(playerid) < 300) return SendClientMessage(playerid, COLOR_RED, "You need to have 300 score to use the  Engineer class");
                        Class_Chosen{ playerid } = false;
                        else //Line 542, error here.
                        SendClientMessage(playerid, COLOR_GREEN, "Engineer class chosen!");
                        SendClientMessage(playerid, COLOR_GREEN, "You can use /fix to repair your own vehicle, and /repair to repair your teammates vehicles");
                        SpawnPlayer(playerid);
                        ResetPlayerWeapons(playerid);
                        SetPlayerSkin(playerid, 50);
                        GivePlayerWeapon(playerid, 16, 1);
                        GivePlayerWeapon(playerid, 24, 157);
                        GivePlayerWeapon(playerid, 27, 127);
                        GivePlayerWeapon(playerid, 31, 540);
                        GivePlayerWeapon(playerid, 35, 2);
                        Class_Chosen{ playerid } = true;
                    }
                }
            }
            return 1;
        }
//Other scripts here
Reply
#2

pawn Код:
Class_Chosen[playerid] = false;
Of course you must
pawn Код:
new bool:Class_Chosen[MAX_PLAYERS];
Reply
#3

Quote:
Originally Posted by ]Rafaellos[
Посмотреть сообщение
pawn Код:
Class_Chosen[playerid] = false;
Of course you must
pawn Код:
new bool:Class_Chosen[MAX_PLAYERS];
I have this..
pawn Код:
new
    Class_Chosen[ MAX_PLAYERS char ]
;
Reply
#4

Then you can't use true or false. Use Class_Chosen[playerid] = 0; for false and 1 for true!
Reply
#5

Sorry for the possibly late answer.
The 0; and 1; is the same as true; and false; imo.
cause i've tried using "0;" and "1;", but it gives me the same Error.
Reply
#6

Quote:
Originally Posted by Kyance
Посмотреть сообщение
Sorry for the possibly late answer.
The 0; and 1; is the same as true; and false; imo.
cause i've tried using "0;" and "1;", but it gives me the same Error.
When you are using true/false on a variable, you must add bool to it.

PHP код:
new Class_Chosen[MAX_PLAYERS char];
Class_Chosenplayerid } = 0
Reply
#7

It should be declared as:
pawn Код:
new
    bool: Class_Chosen[ MAX_PLAYERS char ]
;
By the way, you have an else statement without an if above it.
pawn Код:
Class_Chosen{ playerid } = false;
else //Line 510, error here.
SendClientMessage(playerid, COLOR_GREEN, "Medic class chosen!");
That's wrong, you should remove else from there and in case 0, you forgot to return the message and the code below will be executed.
Reply
#8

Kind of off topic but some friendly advice you should give y_inline/y_dialog a try instead of using OnDialogResponse()
Reply
#9

Well eh, that's not the thing i want.
Basically.
pawn Код:
if(GetPlayerScore(playerid) < 150) SendClientMessage(playerid, COLOR_RED, "You need to have 150 score to use the Sniper class!");
                                                //FORCES the player to choose the class on next death.
                                                //Or just shows the dialog again, but same error
                        else
                        SendClientMessage(playerid, COLOR_GREEN, "Sniper class chosen!");
If the player won't have 150 score, he will have an "error" message, and it will force him to change his class on the next death // Show him the dialog.
Else will happen if the player would have 150 score.. And so on.
I have an /sc script "based" on this.
pawn Код:
CMD:sc(playerid, params[]) {
    Class_Chosen{ playerid } = false; //Sets the Class_Chosen to False, so after he dies, he will be able to change his class.
    SendClientMessage(playerid, COLOR_ORANGE, "Switching class after the next death.");
    return 1;
}
And that Class_Chosen works..
:[
EDIT: Even if i place the Class_Chosen ... = false; in a diff. place, it will still give me that error.

EDIT:Nvm, fixed it, thanks, will +rep when i can.. Currently says that i need to spread some rep for some of you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)