Player exit car + car health -
Qur - 17.11.2011
Hey.. I'm continue work on driving test and I got into a problem...
I want to make that if the player leave the car so the car respawn and he lose the driving test..
I did this but its not working...
public OnPlayerStateChange(playerid, newstate, oldstate)
pawn Код:
if(IsADMV(GetPlayerVehicleID(playerid)))
{
if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT || oldstate == PLAYER_STATE_PASSENGER && newstate == PLAYER_STATE_ONFOOT)
{
new veh;
veh = GetPlayerVehicleID(playerid);
DrivingTest[playerid] = 0;
DisablePlayerCheckpoint(playerid);
SetVehicleToRespawn(veh);
SendClientMessage(playerid,COLOR_RED,"STATUS: You left your car, FAIL!");
return 1;
}
}
Any suggestions? btw.. I tried to put it onplayerexitvehicle but still didnt work..
Re: Detect if player exit car -
sabretur - 17.11.2011
Try this:
pawn Код:
if(IsADMV(GetPlayerVehicleID(playerid)))
{
if((oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER) && newstate == PLAYER_STATE_ONFOOT)
{
DrivingTest[playerid] = 0;
DisablePlayerCheckpoint(playerid);
SetVehicleToRespawn(GetPlayerVehicleID(playerid));
SendClientMessage(playerid,COLOR_RED,"STATUS: You left your car, FAIL!");
return 1;
}
}
Re: Detect if player exit car -
MP2 - 17.11.2011
pawn Код:
if(newstate == 1 && (oldstate == 2 || oldstate == 3))
Notice the brackets.
Re: Detect if player exit car -
antonio112 - 17.11.2011
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(IsADMV(vehicleid))
{
DrivingTest[playerid] = 0;
DisablePlayerCheckpoint(playerid);
SetVehicleToRespawn(vehicleid);
SendClientMessage(playerid,COLOR_RED,"STATUS: You left your car, FAIL!");
}
return 1;
}
Re: Detect if player exit car -
sabretur - 17.11.2011
Quote:
Originally Posted by antonio112
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid) { if(IsADMV(vehicleid)) { DrivingTest[playerid] = 0; DisablePlayerCheckpoint(playerid); SetVehicleToRespawn(vehicleid); SendClientMessage(playerid,COLOR_RED,"STATUS: You left your car, FAIL!"); } return 1; }
|
He said, didn't working with OnPlayerExitVehicle
Re: Detect if player exit car -
Kostas' - 17.11.2011
OnPlayerExitVehicle
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(IsADMV(GetPlayerVehicleID(playerid))) {
new playerState = GetPlayerState(playerid);
if(playerState == PLAYER_STATE_PASSENGER || playerState == PLAYER_STATE_DRIVER) {
DrivingTest[playerid] = 0;
DisablePlayerCheckpoint(playerid);
SetVehicleToRespawn(GetPlayerVehicleID(playerid));
SendClientMessage(playerid,COLOR_RED,"STATUS: You left your car, FAIL!");
return 1;
}
}
// Rest of Code here
return 1;
}
Quote:
Originally Posted by sabretur
He said, didn't working with OnPlayerExitVehicle
|
May he had wrong code
Re: Detect if player exit car -
antonio112 - 17.11.2011
Quote:
Originally Posted by sabretur
He said, didn't working with OnPlayerExitVehicle
|
Because he didn't know how to do it. Trust me, my code works.
Re: Detect if player exit car -
Qur - 17.11.2011
Edit!!
sorry didnt notice that more 5 people replied.. I'll try all of your ideas
Re: Detect if player exit car -
Qur - 17.11.2011
Quote:
Originally Posted by Kostas'
OnPlayerExitVehicle
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid) { if(IsADMV(GetPlayerVehicleID(playerid))) { new playerState = GetPlayerState(playerid); if(playerState == PLAYER_STATE_PASSENGER || playerState == PLAYER_STATE_DRIVER) { DrivingTest[playerid] = 0; DisablePlayerCheckpoint(playerid); SetVehicleToRespawn(GetPlayerVehicleID(playerid)); SendClientMessage(playerid,COLOR_RED,"STATUS: You left your car, FAIL!"); return 1; } } // Rest of Code here return 1; }
May he had wrong code
|
Thanks man! It worked!
and antonio.. I did exactly like you did myself and it didnt work before...
And one the way I have another problem.. just want to ask if its going to work:
pawn Код:
else if(PlayerToPoint(5.0,playerid,1638.0692,-1903.3049,13.4268))
{
new Float:health;
new veh;
veh = GetPlayerVehicleID(playerid);
GetVehicleHealth(veh, health);
if(health >= 700)
{
SendClientMessage(playerid,COLOR_GREEN,"STATUS: You kept the vehicle almost fully unharmed, Passed.");
PlayerInfo[playerid][pCarLic] = 1;
SetVehicleToRespawn(veh);
DrivingTest[playerid] = 0;
DisablePlayerCheckpoint(playerid);
return 1;
}
else
{
SendClientMessage(playerid,COLOR_RED,"STATUS: You failed the test, better luck next time!");
SetVehicleToRespawn(veh);
DrivingTest[playerid] = 0;
DisablePlayerCheckpoint(playerid);
return 1;
}
btw.. I have another part in my script that showing in cars the car health.. so I need to use it? or how I did its okay?
if the car health will get to 70 or lower so the player will fail..
Re: Detect if player exit car -
whitedragon - 17.11.2011
Quote:
Originally Posted by Kostas'
OnPlayerExitVehicle
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid) { if(IsADMV(GetPlayerVehicleID(playerid))) { new playerState = GetPlayerState(playerid); if(playerState == PLAYER_STATE_PASSENGER || playerState == PLAYER_STATE_DRIVER) { DrivingTest[playerid] = 0; DisablePlayerCheckpoint(playerid); SetVehicleToRespawn(GetPlayerVehicleID(playerid)); SendClientMessage(playerid,COLOR_RED,"STATUS: You left your car, FAIL!"); return 1; } } // Rest of Code here return 1; }
May he had wrong code
|
Just looking your code i want ask why you use GetPlayerVehicleID(playerid) ? it get 0 i think. Function have already getting vehicleid in params
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(IsADMV(vehicleid)) {
DrivingTest[playerid] = 0;
DisablePlayerCheckpoint(playerid);
SetVehicleToRespawn(vehicleid);
SendClientMessage(playerid,COLOR_RED,"STATUS: You left your car, FAIL!");
return 1;
}
// Rest of Code here
return 1;
}
I think that my code should work..