Locking a 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: Locking a car? (
/showthread.php?tid=348658)
Locking a car? -
NeymarJr - 06.06.2012
How do I lock a car? I've tried to do it from the SAMP wiki and i keep on getting errorss.. even if i re applied the function in the OnVehicleStreamIn..
Someone help me here please?
Re: Locking a car? -
Neo Karls - 06.06.2012
May this help you much
https://sampforum.blast.hk/showthread.php?tid=246878
https://sampwiki.blast.hk/wiki/SetVehicleParamsForPlayer - Direct wiki samp help
If not tell me , i will explain
Re: Locking a car? -
NeymarJr - 06.06.2012
Quote:
Originally Posted by Neo Karls
|
I've tried from the wiki, and I dont want to add more filterscripts because my server starts getting stuffed...
How do I make a command for locking it?
Re: Locking a car? -
Neo Karls - 06.06.2012
Not sure is it working or not, try this
If yes, tell me
add the below lines to the
public OnPlayerCommandText(playerid, cmdtext[]) seen on your gamemode
pawn Code:
{
if (strcmp(cmdtext, "/lock", true)==0)
{
if(IsPlayerInAnyVehicle(playerid))
{
new State=GetPlayerState(playerid);
if(State!=PLAYER_STATE_DRIVER)
{
SendClientMessage(playerid,0xFF004040,"You can only lock the doors as the driver.");
return 1;
}
new i;
for(i=0;i<MAX_PLAYERS;i++)
{
if(i != playerid)
{
SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 1);
}
}
SendClientMessage(playerid, 0x33AA33AA, "Vehicle locked!");
new Float:pX, Float:pY, Float:pZ;
GetPlayerPos(playerid,pX,pY,pZ);
PlayerPlaySound(playerid,1056,pX,pY,pZ);
}
else
{
SendClientMessage(playerid, 0xFF004040, "You're not in a vehicle!");
}
return 1;
}
if (strcmp(cmdtext, "/unlock", true)==0)
{
if(IsPlayerInAnyVehicle(playerid))
{
new State=GetPlayerState(playerid);
if(State!=PLAYER_STATE_DRIVER)
{
SendClientMessage(playerid,0xFF004040,"You can only unlock the doors as the driver.");
return 1;
}
new i;
for(i=0;i<MAX_PLAYERS;i++)
{
SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 0);
}
SendClientMessage(playerid, 0x33AA33AA, "Vehicle unlocked!");
new Float:pX, Float:pY, Float:pZ;
GetPlayerPos(playerid,pX,pY,pZ);
PlayerPlaySound(playerid,1057,pX,pY,pZ);
}
else
{
SendClientMessage(playerid, 0xFF004040, "You're not in a vehicle!");
}
return 1;
}
return 0;
}
Re: Locking a car? -
Faisal_khan - 06.06.2012
Hey you already posted this
https://sampforum.blast.hk/showthread.php?tid=348133
Re: Locking a car? -
NeymarJr - 07.06.2012
Quote:
Originally Posted by Neo Karls
Not sure is it working or not, try this
If yes, tell me
add the below lines to the
public OnPlayerCommandText(playerid, cmdtext[]) seen on your gamemode
pawn Code:
{ if (strcmp(cmdtext, "/lock", true)==0) { if(IsPlayerInAnyVehicle(playerid)) { new State=GetPlayerState(playerid); if(State!=PLAYER_STATE_DRIVER) { SendClientMessage(playerid,0xFF004040,"You can only lock the doors as the driver."); return 1; } new i; for(i=0;i<MAX_PLAYERS;i++) { if(i != playerid) { SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 1); } } SendClientMessage(playerid, 0x33AA33AA, "Vehicle locked!"); new Float:pX, Float:pY, Float:pZ; GetPlayerPos(playerid,pX,pY,pZ); PlayerPlaySound(playerid,1056,pX,pY,pZ); } else { SendClientMessage(playerid, 0xFF004040, "You're not in a vehicle!"); } return 1; } if (strcmp(cmdtext, "/unlock", true)==0) { if(IsPlayerInAnyVehicle(playerid)) { new State=GetPlayerState(playerid); if(State!=PLAYER_STATE_DRIVER) { SendClientMessage(playerid,0xFF004040,"You can only unlock the doors as the driver."); return 1; } new i; for(i=0;i<MAX_PLAYERS;i++) { SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 0); } SendClientMessage(playerid, 0x33AA33AA, "Vehicle unlocked!"); new Float:pX, Float:pY, Float:pZ; GetPlayerPos(playerid,pX,pY,pZ); PlayerPlaySound(playerid,1057,pX,pY,pZ); } else { SendClientMessage(playerid, 0xFF004040, "You're not in a vehicle!"); } return 1; } return 0; }
|
I got 26 errors, o.O
Re: Locking a car? -
Faisal_khan - 07.06.2012
Paste them here.