problem with this do-while loop
#1

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
Reply
#2

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
Reply
#3

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
Reply
#4

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;
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)