How can I disable exiting a vehicle? -
grand.Theft.Otto - 12.03.2011
You may have seen my previous thread about /kartdm, if not, its ok. What I want is to disable exiting the vehicle when someone attempts to exit the kart. (I just want them to stay in it)
Any idea?
Re: How can I disable exiting a vehicle? -
Tommy_Mandaz - 12.03.2011
Try to use this:
Код:
IsPlayerInVehicle(playerid, gokartid)
Make a timer start once they type the command and then make it loop every couple of seconds so it keeps checking or something close to that. Good luck
Re: How can I disable exiting a vehicle? -
admantis - 12.03.2011
^ No please don't do that.. You can try locking the vehicle using vehicle params (which will probably not work) or put them again when they exit since you can't disable GTA:SA scripts unless the vehicle is locked (i'm sure there's a SA-MP function for that, well, not very sure but huh)
Re: How can I disable exiting a vehicle? -
Tommy_Mandaz - 12.03.2011
Locking the vehicle will only keep the door locked from the outside not inside, that is the only way I can think of that would probably work for what he wants to do...
Re: How can I disable exiting a vehicle? -
admantis - 12.03.2011
I swear I've seen in a server the vehicle being locked from inside aswell. But, that is not the only way, it's just a waste of CPU usage. You can by much better use OnPlayerStateChange or OnPlayerExitVehicle SA:MP callbacks.
Re: How can I disable exiting a vehicle? -
Tommy_Mandaz - 12.03.2011
Yeah that is true it is a waste but he wanted ideas :P That is the only way that comes to mind, but its really not worth it you can just make it like admantis said, OnPlayerExitVehicle and find out if he got out of a gokart and put him back into it or something like that. Good luck dude.
Re: How can I disable exiting a vehicle? -
grand.Theft.Otto - 12.03.2011
I put this under OnPlayerExitVehicle:
pawn Код:
if(IsPlayerInVehicle(playerid, 571)) // 571 = KART ID
{
new rand3 = random(sizeof(RandomSpawn3));
SetPlayerPos(playerid, RandomSpawn3[rand3][0], RandomSpawn3[rand3][1],RandomSpawn3[rand3] [2],RandomSpawn3[rand3][3],RandomSpawn3[rand3][4],RandomSpawn3[rand3][5],RandomSpawn3[rand3][6],RandomSpawn3[rand3][7]);
return 1;
}
The random spawns are for my /kartdm teleport, so if they exit the kart, it will respawn them at a random spot for my command, but it doesn't work for some reason
anyone know why?
Re: How can I disable exiting a vehicle? -
Tommy_Mandaz - 12.03.2011
Код:
if(IsPlayerInVehicle(playerid, 571)) // 571 = KART ID
{
SetPlayerPos(playerid, Randomspawnx, Randomspawny, Randomspawnz || playerid, Randomspawnx, Randomspawny, Randomspawnz || playerid, Randomspawnx, Randomspawny, Randomspawnz);
return 1;
}
Ofcoarse change the randomspawnx, randomspawny, randomspawnz to the coords of the spawns... This should work.
Re: How can I disable exiting a vehicle? -
grand.Theft.Otto - 12.03.2011
No, RandomSpawn3 is the name of the variable, thats exactly what the code is like.
Re: How can I disable exiting a vehicle? -
admantis - 12.03.2011
Quote:
Originally Posted by Tommy_Mandaz
Код:
if(IsPlayerInVehicle(playerid, 571)) // 571 = KART ID
{
SetPlayerPos(playerid, Randomspawnx, Randomspawny, Randomspawnz || playerid, Randomspawnx, Randomspawny, Randomspawnz || playerid, Randomspawnx, Randomspawny, Randomspawnz);
return 1;
}
Ofcoarse change the randomspawnx, randomspawny, randomspawnz to the coords of the spawns... This should work.
|
^ Once again, don't do this. || (logical OR) operator only works in a 'if' statement, not to be used in random operations.
Below code would be
hipotetically the solution, but it's not.
pawn Код:
if(IsPlayerInVehicle(playerid, 571)) // 571 = KART ID
{
switch (random(3))
{
case 0: { SetPlayerPos(playerid, x, y, z); }
case 1: { SetPlayerPos(playerid, x, y, z); }
case 2: { SetPlayerPos(playerid, x, y, z); }
}
}
You are checking if player is in vehicle when player exit it. Is it logical to mind that a player can't be in a vehicle if he exited it. You may want to use OnPlayerStateChange and variables to identify if player is in a kartdm event or not.