[HELP] LOCK WORKING WRONG - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] LOCK WORKING WRONG (
/showthread.php?tid=130313)
[HELP] LOCK WORKING WRONG -
addinol - 26.02.2010
hi, my /lock command works for all cars, i wan't to make it to work only for my own car. if i don't got it it says like: you dont got car.
Код:
if(strcmpEx(cmd, "/lock", true) == 0)
{
if(VehicleLockedPlayer[playerid] != 999)
{
SendClientMessage(playerid, COLOR_WHITE, "You must first unlock your previous vehicle.");
return 1;
}
new carid = GetPlayerVehicleID(playerid);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(VehicleLocked[carid] == 0)
{
if(pStats[playerid][pSex] == 1)
{
PlayerActionMessage(playerid,15.0,"has just locked his vehicle.");
}
else
{
PlayerActionMessage(playerid,15.0,"has just locked her vehicle.");
}
SendClientMessage(playerid,COLOR_WHITE,"Vehicle Locked.");
VehicleLocked[carid] = 1;
VehicleLockedPlayer[playerid] = carid;
}
if(VehicleLocked[carid] == 1)
{
if(pStats[playerid][pSex] == 1)
{
PlayerActionMessage(playerid,15.0,"has just unlocked his vehicle.");
}
else
{
PlayerActionMessage(playerid,15.0,"has just unlocked her vehicle.");
}
SendClientMessage(playerid,COLOR_WHITE,"Vehicle Unlocked.");
VehicleLocked[carid] = 0;
VehicleLockedPlayer[playerid] = 999;
}
}
else if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
{
new Float:x,Float:y,Float:z;
if(VehicleLockedPlayer[playerid] != 999)
{
GetVehiclePos(VehicleLockedPlayer[playerid], x, y, z);
}
if(VehicleLocked[VehicleLockedPlayer[playerid]])
{
if(PlayerToPoint(5.0,playerid,x,y,z) || GetPlayerVehicleID(playerid) == VehicleLockedPlayer[playerid])
{
if(pStats[playerid][pSex] == 1)
{
PlayerActionMessage(playerid,15.0,"has just unlocked his vehicle.");
}
else
{
PlayerActionMessage(playerid,15.0,"has just unlocked her vehicle.");
}
SendClientMessage(playerid,COLOR_WHITE,"Vehicle Unlocked.");
VehicleLocked[VehicleLockedPlayer[playerid]] = 0;
VehicleLockedPlayer[playerid] = 999;
}
else
{
SendClientMessage(playerid,COLOR_WHITE,"You're unable to (un)lock your feet.");
}
}
}
it should look like:
Код:
if(pStats[playerid][pCarModel] == 0;)
{
SendClientMessage(playerid,COLOR_WHITE,"You don't have your own car");
} else {
if(VehicleLocked[carid] == 0)
{
VehicleLocked[carid] = 1;
SendClientMessage(playerid,COLOR_WHITE,"Car has been locked");
}
if(VehicleLocked[carid] == 1)
{
VehicleLocked[carid] = 0;
SendClientMessage(playerid,COLOR_WHITE,"Car has been unlocked");
}
}
The problem is i don't know how to get player's car... HELP ME !
Re: [HELP] LOCK WORKING WRONG -
bajskorv123 - 26.02.2010
pawn Код:
new vehicle;
vehicle = GetPlayerVehicleID(playerid);//Gets the id of the vehicle the player is in
pawn Код:
new model;
model = GetVehicleModel(vehicle);//Gets the model of the vehicle the player is in, needs the function above
Re: [HELP] LOCK WORKING WRONG -
Niixie - 26.02.2010
You need to learn the difference of vehicleid and vehiclemodel.
id is the vehicles id on the server.
model is like 560 = sultan
Re: [HELP] LOCK WORKING WRONG -
addinol - 26.02.2010
you didn't understood me, i wan't that the player can lock only his vehicle, what he bought from Car Shop etc. not which one he is in.
Here is my GM PasteBin