Timer messing it up -
Rudy_ - 21.06.2012
Hello Guys, I have a question about Timers.
Ok, First of all.
I have a Dialog
pawn Код:
ShowPlayerDialog(playerid, 3, DIALOG_STYLE_LIST, "Class Selection", "{FF0000}Bite\n{00FF00}High jump", "Select", "Cancle");
So when player Select High jump it Activates High jump and when select again it De-Activates it...
The problem is I have added a Timer in my High jump Command so they have to wait to use it again, For example.
"I typed /class and select High Jump and jump'd High, and now i can't Jump (This system works fine). But when i type /class again and select High jump then we are able to jump high again without waiting.
Is there any way i can add a Timer in my Dialog or something like that? So if the timer in my High jump script is not Finished then even if they type /class and select > High jump they can't jump?
Would Appreciate.
Re: Timer messing it up -
zombieking - 21.06.2012
pawn Код:
new ClassSelected[MAX_PLAYERS]; // or something like that
new ClassTimerVar;
Now at OnDialogResponse you put:
pawn Код:
if(dialogid == Your Dialog ID here)
{
if(response == The response which will apply the ability)
{
if(ClassSelected[playerid] == 1)
{
SendClientMessage(playerid,color,"text");
}
else
{
ClassSelected[playerid] = 1;
// high jump code here
}
}
}
Now the timer that will reset that:
pawn Код:
forward ClassTimer(playerid);
public ClassTimer(playerid)
{
ClassSelected[playerid] = 0;
KillTimer(ClassTimerVar);
return 1;
}
I didn't test it , so you should test it yourself.
Now at set the timer:
pawn Код:
if(dialogid == Your Dialog ID here)
{
if(response == The response which will apply the ability)
{
if(ClassSelected[playerid] == 1)
{
SendClientMessage(playerid,color,"text");
}
else
{
ClassSelected[playerid] = 1;
ClassTimerVar = SetTimer("ClassTimer",time,false);
// high jump code here
}
}
}
Re: Timer messing it up -
Rudy_ - 21.06.2012
it's not like this , i think i messed everything up, The code is in OnPlayerStateChange
The dialog on Makes it activated - De-activated here let me show you
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 3)
{
if(!response) return ShowPlayerDialog(playerid,-1,0,"","","","");
if(response)
{
switch(listitem)
{
case 0:
{
if(Bite[playerid] == 0)
{
Bite[playerid] = 1;
}
else if(Bite[playerid] == 1)
{
Bite[playerid] = 0;
}
}
case 1:
{
if(IsJumping[playerid] == 0)
{
IsJumping[playerid] = 1;
}
else if(IsJumping[playerid] == 1)
{
IsJumping[playerid] = 0;
}
}
}
}
}
it works fine, but people can abuse it so they don't have to wait for the timer..
Re: Timer messing it up -
Rudy_ - 21.06.2012
-------FIXED---------