Exiting vehicle with sb on -
Stefand - 11.06.2012
Hey,
I made a /sb command, but it have to put the player back in his vehicle if he exits the vehicle when he has his seatbelt on.
But it doesn't work..
this part is under:
pawn Code:
if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
pawn Code:
new string2[128];
if(Player[playerid][Seatbelt] == 1)
{
format(string2, sizeof(string2), "~w~You are still ~r~buckled up");
GameTextForPlayer(playerid, string2, 5000, 3);
new playercar = GetPlayerVehicleID(playerid);
new playerseat = GetPlayerVehicleSeat(playerid);
PutPlayerInVehicle(playerid, playercar, playerseat);
}
and this part is under:
pawn Code:
if(oldstate == PLAYER_STATE_PASSENGER && newstate == PLAYER_STATE_ONFOOT)
pawn Code:
new string3[128];
if(Player[playerid][Seatbelt] == 1)
{
format(string3, sizeof(string3), "~w~You are still ~r~buckled up");
GameTextForPlayer(playerid, string3, 5000, 3);
new playercar1 = GetPlayerVehicleID(playerid);
new playerseat1 = GetPlayerVehicleSeat(playerid);
PutPlayerInVehicle(playerid, playercar1, playerseat1);
}
Re: Help with seatbelt -
Stefand - 11.06.2012
Anyone?
Re: Help with seatbelt -
JhnzRep - 11.06.2012
Bumping only allowed after 48 hours.
Re: Help with seatbelt -
Stefand - 13.06.2012
Sorry didn't know, but it just suck if you wanna compete your script
Re: Help with seatbelt -
PrawkC - 13.06.2012
The problem is playercar1 needs to be a global variable and it needs to be set when the player is in the vehicle, currently you're assigning playercar1 to the players current vehicle WHILE not in a vehicle.
Re: Help with seatbelt -
Stefand - 13.06.2012
How to make it that, he puts the player back in the last vehicle then?
Re: Help with seatbelt -
Stefand - 13.06.2012
is there something like "Getplayerlastvehicleid"
Re: Help with seatbelt -
Jonny5 - 13.06.2012
Quote:
Originally Posted by JhnzRep
Bumping only allowed after 48 hours.
|
and No their is no such function,
you have to make it like stated above
pawn Code:
gLastVeh[MAX_PLAYERS];
public OnPlayerEnterVehicle(playerid , vehicleid)
{
gLastVeh[playerid] = vehicleid;
...
Re: Help with seatbelt -
Stefand - 13.06.2012
Oke, I made this:
pawn Code:
new GetPlayerLastVehicleID[MAX_PLAYERS];
pawn Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
GetPlayerLastVehicleID[playerid] = vehicleid;
return 1;
}
But how to do that with the vehicle seat?
Re: Help with seatbelt -
Jonny5 - 13.06.2012
if its for drive then the seat is 0
off to work
Re: Help with seatbelt -
Stefand - 13.06.2012
Oke now I did what you told me to,
pawn Code:
new GetPlayerLastVehicleID[MAX_PLAYERS];
new GetPlayerLastSeat[MAX_PLAYERS];
pawn Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
GetPlayerLastVehicleID[playerid] = GetPlayerVehicleID(playerid);
GetPlayerLastSeat[playerid] = GetPlayerVehicleSeat(playerid);
return 1;
}
pawn Code:
new string2[128];
if(Player[playerid][Seatbelt] >= 1)
{
new playercar = GetPlayerLastVehicleID[playerid];
new playerseat = GetPlayerLastSeat[playerid];
PutPlayerInVehicle(playerid, playercar, playerseat);
format(string2, sizeof(string2), "~w~You are still ~r~buckled up");
GameTextForPlayer(playerid, string2, 5000, 3);
}
pawn Code:
new string3[128];
if(Player[playerid][Seatbelt] >= 1)
{
new playercar1 = GetPlayerLastVehicleID[playerid];
new playerseat1 = GetPlayerLastSeat[playerid];
PutPlayerInVehicle(playerid, playercar1, playerseat1);
format(string3, sizeof(string3), "~w~You are still ~r~buckled up");
GameTextForPlayer(playerid, string3, 5000, 3);
}
And still not working...
Re: Help with seatbelt -
newbienoob - 13.06.2012
Can't you just use it under OnPlayerKeyStateChange?
pawn Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys == KEY_SECONDARY_ATTACK)
{
if(Player[playerid][Seatbelt] == 1)
{
//..........
}
}
return 1;
}
Re: Help with seatbelt -
Stefand - 13.06.2012
its under "OnPlayerStateChange"
Re: Help with seatbelt -
Stefand - 14.06.2012
anyone?
Re: Help with seatbelt -
Faisal_khan - 14.06.2012
Show your /sb command.
Re: Help with seatbelt -
Stefand - 14.06.2012
pawn Code:
command(sb, playerid, params[])
{
new string[128];
if(IsPlayerInAnyVehicle(playerid))
if(Player[playerid][Seatbelt] == 0)
{
format(string, sizeof(string), "* %s has buckled up his seatbelt.", GetName(playerid));
NearByMessage(playerid, NICESKY, string);
Player[playerid][Seatbelt] = 1;
}
else
if(Player[playerid][Seatbelt] == 1)
{
format(string, sizeof(string), "* %s has unbuckle his seatbelt.", GetName(playerid));
NearByMessage(playerid, NICESKY, string);
Player[playerid][Seatbelt] = 0;
}
return 1;
}
Re: Help with seatbelt -
Faisal_khan - 14.06.2012
Try this:
pawn Code:
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(Player[playerid][Seatbelt] = 1)
{
playerseat = GetPlayerVehicleSeat(playerid);
PutPlayerInVehicle(playerid, playercar, playerseat);
SendClientMessage(playerid, NICESKY, "Unbuckle first!);
}
return 1;
}
Re: Help with seatbelt -
Stefand - 15.06.2012
still not..
Re: Help with seatbelt -
jessejanssen - 15.06.2012
Just a suggestion, click
here.
It'll do the job?
Jesse
Re: Help with seatbelt -
ReneG - 15.06.2012
You have to use OnPlayerExitVehicle, and OnPlayerState, it only gets called when a player is actually out of the car, at which point he has no vehicle ID. That's what I think is causing your code not to work.
Under OnPlayerEnterVehicle, you get the seat id and store it into a global variable. Then on OnPlayerExitVehicle you put them back in the same vehicle with that global var that holds the seat id.
pawn Code:
new
// at the top of your script
gSeatID[MAX_PLAYERS]; // a global var for the seat ID
public OnPlayerStateChange(playerid, newstate, oldstate)
{
// if either they entered as a passenger or driver
// adjust their seat it
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
gSeatID[playerid] = GetPlayerVehicleSeat(playerid);
}
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(Player[playerid][Seatbelt] = 1)
{
// so if the player exits the vehicle
// and they're still buckled up
// you put them back in the vehicle
// in their global seat ID
PutPlayerInVehicle(playerid, vehicleid, gSeatID[playerid]);
/*
* You would put the code that notifies the player
* that they are not unbuckled yet.
*
*/
return 1;
}
return 1;
}