Setting vars to 0 on a call back and also calling it?
#1

pawn Код:
if(duel[playerid] == 1) //
    {
    ForceClassSelection(playerid);
//        duel[playerid] = 0; I also tried to put it here,I don't know but as my players said it is not working.
    }
    duel[playerid] = 0;
Would this actually work? I am asking because the onplayerdeath callback does these all in miliseconds,so maybe it will think the player's duel is 0 and skip the if duel 1 part?
Reply
#2

Yes will work. because its calling once at a time, so will check if is 1, will forceclass the player and then will set the var into 0.

So the next time you will die, will do what you script it to do when is 0.

EDIT:

*Note:

If you use
pawn Код:
if(duel[playerid] == 1) //
{
    ForceClassSelection(playerid);
    duel[playerid] = 0;
}
if(duel[playerid] == 0) //
{
    ForceClassSelection(playerid);
    duel[playerid] = 1;
}
This will set duel to 0, and then will check if is 0, so its, and will set it to 1.
So you have to add an else if

pawn Код:
if(duel[playerid] == 1) //
{
    ForceClassSelection(playerid);
    duel[playerid] = 0;
}
else if(duel[playerid] == 0) //
{
    //do something
    duel[playerid] = 1;
}
If i am wrong, correct me!
Reply
#3

PAWN is single threaded, meaning only one thing will happen at a time. What you're asking about will work, yes.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)