Help with my engine system
#1

PHP код:
CMD:engine(playerid,params[])
{
    for(new 
xGetPlayerVehicleID(playerid); x++)
    {
        if(
vehicleVariables[x][vEngine] == 0)
        {
            new 
vid GetPlayerVehicleID(playerid);
            new 
engine,lights,alarm,doors,bonnet,boot,objective;
            
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
            
SetVehicleParamsEx(vid,1,lights,alarm,doors,bonnet,boot,objective);
            
timer69 SetTimer("fueltimer",20000,true);
            
vehicleVariables[x][vEngine] = 1;
               new 
str[128],pName[MAX_PLAYER_NAME];
            
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
            
format(str,sizeof(str),"%s turns the key of the engine to start the vehicle.",pName);
            
nearByMessage(playeridCOLOR_PURPLEstr5.0);
        }
        else if(
vehicleVariables[x][vEngine] == 1)
        {
            new 
vid GetPlayerVehicleID(playerid),str[128],pName[MAX_PLAYER_NAME];
            new 
engine,lights,alarm,doors,bonnet,boot,objective;
            
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
            
SetVehicleParamsEx(vid,0,lights,alarm,doors,bonnet,boot,objective);
            
KillTimer(timer69);
            
vehicleVariables[x][vEngine] = 0;
            
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
            
format(str,sizeof(str),"%s turns the key of the engine to stop the vehicle.",pName);
            
nearByMessage(playeridCOLOR_PURPLEstr5.0);
        }
        else if(
vehicleVariables[x][vFuel] == 0)
        {
            
SendClientMessage(playerid,COLOR_WHITE,"Vehicle is out of fuel.");
        }
    }
    return 
1;

Reply
#2

And the problem is?
Reply
#3

oh shit, forgot to post it, it spams the message "blahblah has spinned the key and turned the engine on" same with turning it off

I know its somthing with my loop ( Most Likely ) but IDK where to put so it doesnt spam it
Reply
#4

Why are you even using a loop?
Reply
#5

To get the vehicle ID.. but now that I think about it I could just use new x = GetPlayerVehicleID(playerid);?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)