13.01.2013, 04:46
Can anyone assist me with unlocking the car doors when the driver leaves? Getting a bit confused here..
How I lock:
How I unlock:
Getting the vehicle params' the hard part for me.. I'm confused...
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
{
//Now what? Lol
}
return 1;
}
pawn Код:
YCMD:vlock(playerid, params[], help)
{
new string[128];
new vid = GetPlayerVehicleID(playerid);
new State = GetPlayerState(playerid);
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFFFFFFAA, "You have to be inside a vehicle to lock the doors right?");
if(State != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, 0xFFFFFFAA, "You must be the driver of the vehicle to lock it.");
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(i != playerid)
{
SetVehicleParamsForPlayer(vid, i, 0, 1);
}
}
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "* %s locked his/her car doors.", sendername);
SendClientMessage(playerid, 0xFFFF00AA, "Vehicle locked!");
new Float:pX, Float:pY, Float:pZ;
GetPlayerPos(playerid,pX,pY,pZ);
PlayerPlaySound(playerid,1056,pX,pY,pZ);
return 1;
}
pawn Код:
YCMD:vunlock(playerid, params[], help)
{
new string[128];
new vid = GetPlayerVehicleID(playerid);
new State = GetPlayerState(playerid);
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFFFFFFAA, "You have to be inside a vehicle to unlock the doors right?");
if(State != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, 0xFFFFFFAA, "You must be the driver of the vehicle to unlock it.");
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(i != playerid)
{
SetVehicleParamsForPlayer(vid, i, 0, 0);
}
}
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "* %s unlocked his/her car doors.", sendername);
SendClientMessage(playerid, 0xFFFF00AA, "Vehicle unlocked!");
new Float:pX, Float:pY, Float:pZ;
GetPlayerPos(playerid,pX,pY,pZ);
PlayerPlaySound(playerid,1057,pX,pY,pZ);
return 1;
}