/lock house car - 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)
+--- Thread: /lock house car (
/showthread.php?tid=400631)
/lock house car -
Alex0 - 19.12.2012
Hello guys , i got a little problem with /lock command to lock/unlock my house car
So i buyed a house , the car was locked , i typed /lock and a message telled me it's unlocked but is still locked
Here is my /lock command
pawn Код:
//----------------------------------[LOCK]--------------------------------------
if(strcmp(cmd, "/lock", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new carid;
if (gTeam[playerid] == 2 || gTeam[playerid] == 1)
{
if(gLastCar[playerid] == 0 && PlayerInfo[playerid][pPhousekey] == 255)
{
SendClientMessage(playerid, COLOR_GRAD2, " You dont have a Vehicle.");
return 1;
}
else if(gLastCar[playerid] != 0 && gLastCar[playerid] != PlayerInfo[playerid][pPhousekey]+1)
{
if (HireCar[playerid] != gLastCar[playerid] && HireCar[playerid] != 299)
{
gLastDriver[HireCar[playerid]] = 300;
gCarLock[HireCar[playerid]] = 0;
UnLockCar(HireCar[playerid]);
}
HireCar[playerid] = gLastCar[playerid];
}
}
if (PlayerInfo[playerid][pPhousekey] == 255)
{
if(HireCar[playerid] == 299)
{
SendClientMessage(playerid, COLOR_GRAD2, " You dont have a Vehicle.");
return 1;
}
}
carid = PlayerInfo[playerid][pPhousekey]+1;
if(HireCar[playerid] != 299 && !SwitchKey[playerid])
{
carid = HireCar[playerid];
}
//new driver = gLastDriver[carid];
new lockstatus = gCarLock[carid];
new Float:cx,Float:cy,Float:cz;
GetVehiclePos(carid, cx, cy, cz);
switch (lockstatus)
{
case 0:
{
if(HireCar[playerid] == 484 || IsACopCar(carid))
{
SendClientMessage(playerid, COLOR_GRAD2, " You can`t lock this car.");
return 1;
}
if(HireCar[playerid] == 299 && PlayerInfo[playerid][pPhousekey] == 255)
{
SendClientMessage(playerid, COLOR_GRAD2, " You dont have a Vehicle");
return 1;
}
if(HireCar[playerid] == carid && !SwitchKey[playerid])
{
GameTextForPlayer(playerid, "~w~Hire Vehicle ~r~Locked", 5000, 6);
PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
gCarLock[carid] = 1;
LockCar(carid);
}
else if (PlayerInfo[playerid][pPhousekey] == carid-1)
{
GameTextForPlayer(playerid, "~w~House Vehicle ~r~Locked", 5000, 6);
PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
gCarLock[carid] = 1;
LockCar(carid);
return 1;
}
}
case 1:
{
if(HireCar[playerid] == 299 && PlayerInfo[playerid][pPhousekey] == 255)
{
SendClientMessage(playerid, COLOR_GRAD2, " You dont have a Vehicle");
return 1;
}
if(HireCar[playerid] == carid && !SwitchKey[playerid])
{
GameTextForPlayer(playerid, "~w~Hire Vehicle ~g~Unlocked", 5000, 6);
PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
gCarLock[carid] = 0;
UnLockCar(carid);
}
if (PlayerInfo[playerid][pPhousekey] == carid-1)
{
GameTextForPlayer(playerid, "~w~House Vehicle ~g~Unlocked", 5000, 6);
PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
gCarLock[carid] = 0;
UnLockCar(carid);
return 1;
}
}
default:
{
SendClientMessage(playerid, COLOR_GRAD2, " Error");
}
}
if(carid == 1000)
{
SendClientMessage(playerid, COLOR_GRAD2, " You dont have a Vehicle !");
}
}
return 1;
}
Re: /lock house car -
LarzI - 19.12.2012
Show us your UnLockCar function
Re: /lock house car -
B-Matt - 19.12.2012
Use this
https://sampwiki.blast.hk/wiki/SetVehicleParamsForPlayer , SetVehicleParamsForPlayer.
So for your lock command is:
PHP код:
SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid), i, 0, 1/0); //1/0 is doorslock
Re: /lock house car -
Alex0 - 19.12.2012
I am a bit newbie to scripting ... i think this is the fuction ?
pawn Код:
public UnLockCar(carid)
{
for(new i = 0; i <= MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(!IsAPlane(carid))
{
SetVehicleParamsForPlayer(carid,i,0,0);
}
}
}
}
And B-matt can you make that command for me , i am a bet newbie to scripting , pleaze if you can help me ..
Re: /lock house car -
Alex0 - 20.12.2012
Pleaze anyone ?
Re: /lock house car -
LarzI - 20.12.2012
How is HireCar declared? Is it set to an vehicle ID?