Wait Function
#1

Hey all. I have a question about the wait function. i cant get it working. can someone help me?
The problem is with my tune script. When i tune a car i play a sound, but i wanna hear the sound twice. not just once.
So what i try is like this:

AddVehicleComponent(GetPlayerVehicleID(playerid), 1007); // Left Side Skirt
AddVehicleComponent(GetPlayerVehicleID(playerid), 1017); // Right Side Skirt
PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
Wait(1000);
PlayerPlaySound(playerid,1133,0.0,0.0,0.0);

When i run it. i get this error: error 017: undefined symbol "Wait"

Can someone help me? Thnx in advance
Reply
#2

Wait(time) is not a native SAMP fuction.

You may use a timer.
Reply
#3

pawn Код:
AddVehicleComponent(GetPlayerVehicleID(playerid), 1007); // Left Side Skirt
AddVehicleComponent(GetPlayerVehicleID(playerid), 1017); // Right Side Skirt
PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
SetTimerEx("Wait", 1000, false, "i", playerid);

forward Wait(playerid); // End of your script out of any callback.
public Wait(playerid)
{
  PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
}
Reply
#4

It doesnt seem to work...

Now i get these errors:

error 029: invalid expression, assumed zero
error 017: undefined symbol "Wait"
error 029: invalid expression, assumed zero
error 017: undefined symbol "Wait"


Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/tune", cmdtext, true, 10) == 0)
    {
        if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 405)
				{
           AddVehicleComponent(GetPlayerVehicleID(playerid), 1010); // Nitro
	      AddVehicleComponent(GetPlayerVehicleID(playerid), 1087); // Hydraulics
	      AddVehicleComponent(GetPlayerVehicleID(playerid), 1001); // Spoiler
	      AddVehicleComponent(GetPlayerVehicleID(playerid), 1006); // Roof Scoop
        	AddVehicleComponent(GetPlayerVehicleID(playerid), 1007); // Left Side Skirt
		AddVehicleComponent(GetPlayerVehicleID(playerid), 1017); // Right Side Skirt
		PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
		SetTimerEx("Wait", 1000, false, "i", playerid);

		forward Wait(playerid);
		public Wait(playerid)
		{
  		PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
		}

	 }
	 }
	 }
Reply
#5

You can use this function: »

halt(seconds)
{
new _newTime[4], _oldTime[4];
gettime(_oldTime[0], _oldTime[1], _oldTime[2]);
_oldTime[3] = _oldTime[2] + (_oldTime[1] * 60) + (_oldTime[0] * 600);

while(_newTime[3] != (_oldTime[3] + seconds))
{
gettime(_newTime[0], _newTime[1], _newTime[2]);
_newTime[3] = _newTime[2] + (_newTime[1] * 60) + (_newTime[0] * 600);
}
}


And use halt(1); to wait 1 second.
Reply
#6

Thnx man, it works
Reply
#7

Quote:
Originally Posted by » RyDeR «
You can use this function: »

halt(seconds)
{
new _newTime[4], _oldTime[4];
gettime(_oldTime[0], _oldTime[1], _oldTime[2]);
_oldTime[3] = _oldTime[2] + (_oldTime[1] * 60) + (_oldTime[0] * 600);

while(_newTime[3] != (_oldTime[3] + seconds))
{
gettime(_newTime[0], _newTime[1], _newTime[2]);
_newTime[3] = _newTime[2] + (_newTime[1] * 60) + (_newTime[0] * 600);
}
}


And use halt(1); to wait 1 second.
That will freeze the server for every player -.-

Quote:
Originally Posted by dirtychester
Thnx man, it works
Use a timer as Killa_ suggested.
Reply
#8

I dont recommend you to use the halt function, it freezes your script and server, so no one can join, timers stop working, nothing gets called and it affects everyone on your server.
Reply
#9

Quote:
Originally Posted by OnTop2K9
Quote:
Originally Posted by » RyDeR «
You can use this function: »

halt(seconds)
{
new _newTime[4], _oldTime[4];
gettime(_oldTime[0], _oldTime[1], _oldTime[2]);
_oldTime[3] = _oldTime[2] + (_oldTime[1] * 60) + (_oldTime[0] * 600);

while(_newTime[3] != (_oldTime[3] + seconds))
{
gettime(_newTime[0], _newTime[1], _newTime[2]);
_newTime[3] = _newTime[2] + (_newTime[1] * 60) + (_newTime[0] * 600);
}
}


And use halt(1); to wait 1 second.
That will freeze the server for every player -.-

Quote:
Originally Posted by dirtychester
Thnx man, it works
Use a timer as Killa_ suggested.
I didn't make it.
Reply
#10

Ok true about that. that's kinda gay :P, But i cant get the timer working.... i am a noob scripter lol.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)