Same command, two functions - Won't work. Help! - 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: Same command, two functions - Won't work. Help! (
/showthread.php?tid=259461)
Same command, two functions - Won't work. Help! -
Kasis - 04.06.2011
I know I am doing wrongly, but I can't find how to do it correctly. So, Maybe somebody can help me?
pawn Код:
if(strcmp("/engine", cmdtext, true) == 0)
{
new vid = GetPlayerVehicleID(playerid);
if(vid != INVALID_VEHICLE_ID)
{
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
}
else if(strcmp("/engine", cmdtext, true) == 0)
{
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
}
return 1;
}
Re: Same command, two functions - Won't work. Help! -
Wesley221 - 04.06.2011
pawn Код:
if(strcmp("/engine", cmdtext, true) == 0)
{
new vid = GetPlayerVehicleID(playerid);
new engine[MAX_PLAYERS];
if(vid != INVALID_VEHICLE_ID)
{
if(engine[playerid] == 0);
{
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
engine[playerid] = 1;
}
else if(engine[playerid] == 1)
{
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
engine[playerid] = 0;
}
}
return 1;
}
Should be something like this
Re: Same command, two functions - Won't work. Help! -
xalith - 04.06.2011
just add this on top
new engine[MAX_PLAYERS];
then let the server check if the engine is on
if(engine[playerid] == 1) { //it is on
..........
}else{
if(engine[playerid] == 0){ //engine is off
......
and ofcoz after turning on the engine, tell the server engine is on
engine[playerid] = 1;
and same when off
engine[playerid] = 0;
Re: Same command, two functions - Won't work. Help! -
Kasis - 04.06.2011
Thanks guys! You really helped me with this and others things also.