Lock vehicle -
STONEGOLD - 22.07.2015
How can i lock last vehicle?
Well, I want player can lock their vehicle when they are outside. So, I want to get player last vehicle for locking and unlocking.
Re: Lock vehicle -
dominik523 - 22.07.2015
We don't know anything from your vehicle system (enums...) so we can't really help you until you provide some codes.
Re: Lock vehicle -
STONEGOLD - 22.07.2015
I don't have anything yet. I want to know how can i do this?
Re: Lock vehicle -
xVIP3Rx - 22.07.2015
Save their current vehicle ID in a variable when they enter a vehicle, use it to look it when he's outside..
pretty easy
tell me if you need codes.
Re: Lock vehicle -
STONEGOLD - 22.07.2015
Yes i need codes.
Re: Lock vehicle -
xVIP3Rx - 22.07.2015
pawn Код:
new CurrentVehicle[MAX_PLAYERS] = { -1, ... };
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
CurrentVehicle[playerid] = GetPlayerVehicleID(playerid);
}
return 1;
}
//When you want to lock the car use CurrentVehicle[playerid] as the vehicle id, make sure it isn't -1 though
CMD:lock(playerid, params[])
{
if(CurrentVehicle[playerid] != -1)
{
for(new i, j = GetPlayerPoolSize(); i <= j; i++) // note that we assign the return value to a new variable (j) to avoid calling the function with each iteration
{
if(i != playerid) SetVehicleParamsForPlayer(CurrentVehicle[playerid],i,0,1);
}
}
return 1;
}
Re: Lock vehicle -
STONEGOLD - 22.07.2015
undefined symbol "GetPlayerPoolSize"
Re: Lock vehicle -
xVIP3Rx - 22.07.2015
You're not using samp 0.3z R2, update your server or use MAX_PLAYERS or foreach instead.
pawn Код:
new CurrentVehicle[MAX_PLAYERS] = { -1, ... };
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER) CurrentVehicle[playerid] = GetPlayerVehicleID(playerid);
return 1;
}
//When you want to lock the car use CurrentVehicle[playerid] as the vehicle id, make sure it isn't -1 though
CMD:lock(playerid, params[])
{
if(CurrentVehicle[playerid] != -1)
{
for(new i, j = MAX_PLAYERS; i <= j; i++) // note that we assign the return value to a new variable (j) to avoid calling the function with each iteration
{
if(IsPlayerConnected(i) && i != playerid) SetVehicleParamsForPlayer(CurrentVehicle[playerid],i,0,1);
}
}
return 1;
}
Re: Lock vehicle -
STONEGOLD - 22.07.2015
Well, It says locked but i can still enter without unlock? and i m using samp 0.3z R2 now.
Re: Lock vehicle -
xVIP3Rx - 22.07.2015
yeah, it's locked for everybody except you, do you wanna lock if for everybody ?
if so, just remove "if(i != playerid)"
or try this
pawn Код:
new CurrentVehicle[MAX_PLAYERS] = { -1, ... };
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER) CurrentVehicle[playerid] = GetPlayerVehicleID(playerid);
return 1;
}
CMD:lock(playerid, params[])
{
new vehicleid = CurrentVehicle[playerid];
if(vehicleid != -1)
{
new doors, engine, lights, alarm, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid, engine, lights, alarm, VEHICLE_PARAMS_OFF, bonnet, boot, objective);
}
return 1;
}