Why doesn't this code work? - 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: Why doesn't this code work? (
/showthread.php?tid=90614)
Why doesn't this code work? -
ThePS3Guy - 09.08.2009
Before I post the code, credit for this goes to ev0lutionnn
public OnPlayerStateChange(playerid,newstate,oldstate)
{
if((newstate == 4) && (oldstate == 2)) { // State 4 = Exiting a vehicle, State 2 = Driver - This makes sure he is now exiting the vehicle, and he was the driver (not a passenger)
DestroyVehicle(GetPlayerVehicleID(playerid)); // Not sure if this works because he technically isn't in a vehicle, but I think it should still return his vehicle ID
}
return 1;
}
It compiles correctly, and it "looks" like it should work (opinion of a noob scripter, me) but it just doesn't work.
PS: how do I post scripts in that Pawno script box that everyone seems to use? I searched and I cant find it. I found the samp pastebin, but I cant find out how to post that into a post
Re: Why doesn't this code work? -
ruarai - 09.08.2009
if your going to only do this when a player exits a vehicle use public OnPlayerExitVehicle(playerid, vehicleid)
like:
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
DestroyVehicle(vehicleid);
return 1;
}
However the vehicle wont respawn so you should use SetVehicleToRespawn(1);
so this should respawn the vehicle
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
SetVehicleToRespawn(1);
return 1;
}
Re: Why doesn't this code work? -
ThePS3Guy - 09.08.2009
Thanks яυαяαι u saved my from worrying about figuring something else out...
Re: Why doesn't this code work? -
ruarai - 09.08.2009
No problem
Re: Why doesn't this code work? -
ThePS3Guy - 09.08.2009
Wait.. it compiles properly.. but it doesn't work. It looks like it should. I even tried putting it in it's own filter script to make sure. When I exit a car it just stays there. Does anyone know what's wrong here?
Thanks for the code btw it solves 2 problems at once when I get it working
Re: Why doesn't this code work? -
ruarai - 09.08.2009
oh wait.... i failed
it should be SetVehicleToRespawn(vehicleid);
Re: Why doesn't this code work? -
ThePS3Guy - 09.08.2009
OK thanks a lot. The more mistakes u make the more i learn so... wasn't all that bad.