Engine Command - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Server (
https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (
https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: Engine Command (
/showthread.php?tid=303251)
Engine Command -
James.Clement - 12.12.2011
Does anyone have a CMD:engine and CMD:light command they can spare me so i can put it in my script?
My players keep pestering me about not having a engine/light system.
I want a trunk and hood system too but right now a engine and light system works.
Re: Engine Command -
DonWade - 12.12.2011
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if (newkeys == KEY_FIRE)
{
new string[128];
new vehicleid = GetPlayerVehicleID(playerid);
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(engine == 0)
{
SetVehicleParamsEx(vehicleid, 1, lights, alarm, doors, bonnet, boot, objective);
TogglePlayerControllable(playerid,0);
SetTimerEx("Unfreeze", 2000, 0, "i", playerid);
for(new i=0; i<MAX_PLAYERS; i++)
{
if(GetDistanceBetweenPlayers(playerid,i) < 20)
{
format(string,sizeof(string),"%s(%d) spins the vehicle's engine key and turns on the engine.",PlayerName(playerid),playerid);
SendClientMessage(i,COLOR_SERVER,string);
SendClientMessage(playerid,COLOR_SERVER,"Engine Successfully started!");
}
}
}
else
{
TogglePlayerControllable(playerid,0);
SetTimerEx("Unfreeze", 1000, 0, "i", playerid);
SetVehicleParamsEx(vehicleid, 0, lights, alarm, doors, bonnet, boot, objective);
SendClientMessage(playerid,COLOR_RED,"Engine Turned Off!");
}
}
}
return 1;
}
that is for engine ...starting engine with left mouse click ,, you can edit it ,, and for lights princip is same , just instead that engine parametar change lights parametar
Re: Engine Command -
James.Clement - 12.12.2011
Thank you very much i really needed this!
Re: Engine Command -
DonWade - 12.12.2011
Put that code under public OnPlayerCommandText(playerid, cmdtext[]) instead of OnPlayerKeyStateChange(playerid, newkeys, oldkeys) and just add : example
if (strcmp("/engine", cmdtext, true, 10) == 0) instead of my if (newkeys == KEY_FIRE) and thats it