Vehicle In Use - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Vehicle In Use (
/showthread.php?tid=231803)
Vehicle In Use -
lewismichaelbbc - 26.02.2011
Hi, i have a problem.
Only one person can join my minigame only. How can i do this? my only idea is a pawno code that checks to see if the car is in use, if it is the player can't join. and if the car is not being used, the player can join.
Is this possible?
Thanks!
Re: Vehicle In Use -
maramizo - 26.02.2011
I.
Have no idea what the fuck you're talkin about.
Re: Vehicle In Use -
lewismichaelbbc - 26.02.2011
lol. I need a command that will allow a player to enter a vehicle from a command if the vehicle is not in-use
Re: Vehicle In Use -
Mike Garber - 26.02.2011
I just made this, yes it's been made before but w/e.
Put this anywhere in ur script, not inside a callback.
pawn Код:
stock IsVehicleOccupied(vehicleid) // Returns 1 if there is anyone in the vehicle
{
foreach(Player,i)
{
if(IsPlayerInAnyVehicle(i))
{
if(GetPlayerVehicleID(i)==vehicleid)
{
return 1;
}
else
{
return 0;
}
}
}
}
USAGE: IsVehicleOccupied(vehicleid)
EXAMPLE:
pawn Код:
if(IsVehicleOccupied(100)) // Change 100 to the vehicleid you need to check
{
SendClientMessage(playerid,-1,"Sorry, you cannot enter the minigame at this time.");
}
else
{
SendClientMessage(playerid,-1,"Welcome to the minigame!");
}
You need to include this;
https://sampforum.blast.hk/showthread.php?tid=92679
Re: Vehicle In Use -
lewismichaelbbc - 26.02.2011
Hi, thank you very much for the code but there is still one more problem!
pawn Код:
if (strcmp("/monsterjump", cmdtext, true, 10) == 0)
(
if(IsVehicleOccupied(monster)) // This is line 98 with the errors
{
SendClientMessage(playerid,0xFFFF00AA,"Sorry, you cannot enter the minigame at this time.");
}
else
{
DestroyVehicle(monster);
monster = CreateVehicle(444,1391.2715,2192.8772,11.3947,138.2573, 0.0,-1,-1,5000);
PutPlayerInVehicle(playerid, monster);
TogglePlayerControllable(playerid, 0);
SendClientMessage(playerid, 0xFFFF00AA, "Welcome To MonsterJump!");
Timer0 = SetTimerEx("monsterjump0",5000,false, "i", playerid);
KillTimer(Timer1);
KillTimer(Timer2);
KillTimer(Timer3);
}
return 1;
}
Please can you check the line 'isvehicleoccupied' i am getting many errors on that line:
pawn Код:
C:\Users\Lewis\Desktop\K+J Stunts\filterscripts\monsterjump.pwn(97 -- 98) : error 029: invalid expression, assumed zero
C:\Users\Lewis\Desktop\K+J Stunts\filterscripts\monsterjump.pwn(98) : warning 217: loose indentation
C:\Users\Lewis\Desktop\K+J Stunts\filterscripts\monsterjump.pwn(98) : error 001: expected token: ";", but found ")"
C:\Users\Lewis\Desktop\K+J Stunts\filterscripts\monsterjump.pwn(98) : error 029: invalid expression, assumed zero
C:\Users\Lewis\Desktop\K+J Stunts\filterscripts\monsterjump.pwn(98) : fatal error 107: too many error messages on one line
Re: Vehicle In Use -
Mike Garber - 26.02.2011
Did you define a number or vehicle to "monster" ?
I don't get any errors though.
Re: Vehicle In Use -
lewismichaelbbc - 26.02.2011
Fantastic! That is what i forgot to do lol. Fixed. Thank you very much