problem with this do-while loop - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: problem with this do-while loop (
/showthread.php?tid=414401)
problem with this do-while loop -
akki - 09.02.2013
i am having problems with the do-while loop i am using
the coding is:
Код:
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 456)
{ new Float:rot,rep = -1;
SendClientMessage(playerid,COLOR_YELLOW,"your truck will now start loading");
TogglePlayerControllable(playerid,0);
GetVehicleZAngle(GetPlayerVehicleID(playerid),rot);
do
{
if(rot < 233.0822 && rot > 223.0822)
{
SetTimer("truckloading",7000,0);
rep=0;
}
else
{
SendClientMessage(playerid,COLOR_GREY,"set you truck facing towards garage in order to loadtruck");
rep=1;
}
}while(rep == 1);
}
else
SendClientMessage(playerid,COLOR_GREY,"you are not in a yankee");
the do-while ends up in an infinite loop and which causes a game crash because of too many messages to the player
please help me
Re: problem with this do-while loop -
FUNExtreme - 09.02.2013
Option 1: Check it with a timer instaid of a continues loop
Option 2: have a variable store if the message was already shown, that way you can show it only once
Re: problem with this do-while loop -
akki - 09.02.2013
Quote:
Originally Posted by FUNExtreme
Option 1: Check it with a timer instaid of a continues loop
Option 2: have a variable store if the message was already shown, that way you can show it only once
|
can you explain me about the second option coz i don't know about it much
Re: problem with this do-while loop -
FUNExtreme - 09.02.2013
If you don't understand this then start with doing something within your capabilities. You'll have a lot more fun and it'll learn faster. Good luck
pawn Код:
else
{
if(variable == 0)
{
SendClientMessage(playerid,COLOR_GREY,"set you truck facing towards garage in order to loadtruck");
rep=1;
variable = 1;
}
}