[HELP] /engine 2 functions -
Stefand - 03.06.2012
Hello,
I wanna make my /engine command for Engine On and engine off
But how can i do it.
pawn Код:
if (strcmp("/engine", cmdtext, true, 10) == 0)
{
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(GetPlayerVehicleID(playerid),VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
GetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective);
if(engine == VEHICLE_PARAMS_ON){
SetVehicleParamsEx(GetPlayerVehicleID(playerid),VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
}
return 1;
}
won't work...
AW: [HELP] /engine 2 functions -
RPG-Zone - 03.06.2012
Try this:
Код:
if(strcmp(cmd, "/engine",true) == 0) {
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return 1;
new engine,lights,alarm,doors,bonnet,boot,objective;
new vid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
if(vid != INVALID_VEHICLE_ID) {
if(engine == VEHICLE_PARAMS_ON)
{
SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~W~Engine ~r~Off!", 2000, 5);
}
else
{
SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~W~Engine ~g~On!", 2000, 5);
}
}
return 1;
}
Re: [HELP] /engine 2 functions -
Edward156 - 03.06.2012
This should get you a bit more organised:
pawn Код:
if (!strcmp("car", cmdtext[1], true, 3))
{
if (cmdtext[4] != ' ') return SendClientMessage(playerid, 0xff0000ff, "Usage: /car engine or /car lights /car whatsoever");
if (!strcmp("engine", cmdtext[5], true, 6))
{
// user typed /car engine
// put functions here
}
else if (!strcmp("lights", cmdtext[5], true, 6))
{
// user typed /car lights
// put functions here
}
else if (!strcmp("boot", cmdtext[5], true, 4))
{
// user typed /car boot
// put functions here
}
else return SendClientMessage(playerid, 0xff0000ff, "Error: unknown /car command.");
return 1;
}