[Solved]problems with engine -
horsemeat - 16.04.2013
What is the problem with the engine
pawn Код:
CMD:engine(playerid, params[])
{
if(IsPlayerInAnyVehicle(playerid))
{
new vehicleid = GetPlayerVehicleID(playerid);
new engine,lights,alarm,doors,bonnet,boot,objective;
new name[128],dostring[128];
GetPlayerName(playerid,name,sizeof(name));
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
if(engine ==0)
{
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
for(new i;i < MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
if(IsPlayerInRangeOfPoint(i,5.0,x,y,z))
{
SendClientMessage(i, PURPLE, dostring);
}
}
}
SendClientMessage(playerid, PURPLE,"Car Starting please wait");
engine = true;
lights = true;
carstarttimer[vehicleid] = SetTimerEx("CarStart",3000,false,"iiiiiiiii",playerid,vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
}
else if(engine == 1)
{
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
for(new i;i < MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
if(IsPlayerInRangeOfPoint(i,5.0,x,y,z))
{
SendClientMessage(i, PURPLE, dostring);
}
}
}
SendClientMessage(playerid, PURPLE,dostring);
SetVehicleParamsEx(vehicleid,false,false,alarm,doors,bonnet,boot,objective);
}
else
{
SendClientMessage(playerid, DARKBLUE, "~BETA~engine fail");
}
}
else
{
SendClientMessage(playerid,RED,"You have to be in a car inorder to turn on the engine");
}
return 1;
}
Here is another function witch is part of this
pawn Код:
public CarStart(playerid,vehicleid,engine,lights,alarm,doors,bonnet,boot,objective)
{
SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
KillTimer(carstarttimer[vehicleid]);
SendClientMessage(playerid, "Car Has Started");
return 1;
}
Every time I use /engine nothing happens so i put in another else statement and i confirm that it is that
Note I removed some of the code so if something is missing don't be alarmed
make sure to see if the engine value is -1
pawn Код:
CMD:engine(playerid, params[])
{
new vehicleid = GetPlayerVehicleID(playerid);
if(IsPlayerInAnyVehicle(playerid))
{
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
if((engine)==-1)
{
engine = 0;
}
if((engine)==0)
{
SendClientMessage(playerid, DARKBLUE,"Engine on");
SetVehicleParamsEx(vehicleid,true,lights,alarm,doors,bonnet,boot,objective);
}
else if((engine)==1)
{
SendClientMessage(playerid, DARKBLUE,"Engine off");
SetVehicleParamsEx(vehicleid,false,lights,alarm,doors,bonnet,boot,objective);
}
/*else if((engine)== )
{
SendClientMessage(playerid, DARKBLUE, "Engine -1 problem");
}*/
else
{
SendClientMessage(playerid, DARKBLUE,"Engine Fail");
}
}
return 1;
}
Re : problems with engine -
DaTa[X] - 16.04.2013
pawn Код:
public CarStart(playerid,vehicleid,engine,lights,alarm,doors,bonnet,boot,objective)
{
SetVehicleParamsEx(vehicleid,1,lights,alarm,doors,bonnet,boot,objective);
KillTimer(carstarttimer[vehicleid]);
SendClientMessage(playerid, "Car Has Started");
return 1;
}
try this
AW: problems with engine -
ulbi1990 - 16.04.2013
Why making such a mess?
Just do it this way:
Place this timer instead of yours:
pawn Код:
SetTimerEx("CarStart",3000,0,"i",playerid);
and than this:
pawn Код:
forward CarStart(playerid);
public CarStart(playerid)
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(GetPlayerVehicleID(playerid),1,lights, alarm,doors, bonnet, boot, objective);
return 1;
}
Btw both of you should watch the syntax of SendClientMessage which isn't playerid,text[] but for this playerid,color,text[]
pawn Код:
//Wrong
SendClientMessage(playerid, "Car Has Started");
//Correct
SendClientMessage(playerid,Some Freaky Color,"Car Has Started");
And why does you kill a not repeating Timer? I don't understand if you even know what you script.
Re: problems with engine -
horsemeat - 16.04.2013
thaks for the tip but i have already narrow it down to the
pawn Код:
if((engine == 0)
{
}
else if((engine ==1)
{
}
else
{
SendClientMessage(playerid, DARKBLUE, "~BETA~engine fail");
}
becuse the message engine fail appears
Re: problems with engine -
horsemeat - 17.04.2013
I was looking threw the forms and found this
Quote:
Originally Posted by Vince
Also check if engine is -1.
|
Thanks Vince you solved my problem