Wait Function -
dirtychester - 13.05.2010
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
Re: Wait Function -
DJDhan - 13.05.2010
Wait(time) is not a native SAMP fuction.
You may use a timer.
Re: Wait Function -
Killa_ - 13.05.2010
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);
}
Re: Wait Function -
dirtychester - 13.05.2010
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);
}
}
}
}
Re: Wait Function -
RyDeR` - 13.05.2010
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.
Re: Wait Function -
dirtychester - 13.05.2010
Thnx man, it works
Re: Wait Function -
On_Top_Non_Stop - 13.05.2010
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.
Re: Wait Function -
Killa_ - 13.05.2010
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.
Re: Wait Function -
RyDeR` - 13.05.2010
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.
Re: Wait Function -
dirtychester - 13.05.2010
Ok true about that. that's kinda gay :P, But i cant get the timer working.... i am a noob scripter lol.