Why doesn't this code work?
#1

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
Reply
#2

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;
}

Reply
#3

Thanks яυαяαι u saved my from worrying about figuring something else out...
Reply
#4

No problem
Reply
#5

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
Reply
#6

oh wait.... i failed
it should be SetVehicleToRespawn(vehicleid);
Reply
#7

OK thanks a lot. The more mistakes u make the more i learn so... wasn't all that bad.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)