27.03.2012, 22:53
Well, alright, heres my problem.
I'm currently making a simple engine system for my script. All cars, by default, are spawned with their engines off. Now, when I type in /engine when not in my vehicle, it says "You are not driving a vehicle!". If I am actually inside the vehicle, it responds with "Server: Unknown command". Probably an easy fix, I just don't see whats wrong with it.
Thanks in advance,
Stevolas. Help is appreciated.
EDIT: Felt I should include some more information
I'm currently making a simple engine system for my script. All cars, by default, are spawned with their engines off. Now, when I type in /engine when not in my vehicle, it says "You are not driving a vehicle!". If I am actually inside the vehicle, it responds with "Server: Unknown command". Probably an easy fix, I just don't see whats wrong with it.
pawn Код:
CMD:engine(playerid, params[])
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) //This here is checking if the player is inside a vehicle as a driver.
{
new vehicle = GetPlayerVehicleID(playerid); //This part here is defining the vehicle ID that the player is currently in.
new vehicleid;
new pname[24];
pname = GetName(playerid);
new string[100];
if(VEngine[vehicle] == 0) //This is checking if the engine of the vehicle, is turned off or not.
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
VEngine[vehicle] = 1;
SetVehicleParamsEx(vehicle, 1, lights, alarm, doors, bonnet, boot, 0);
}
else
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
VEngine[vehicle] = 0;
SetVehicleParamsEx(vehicle, 1, lights, alarm, doors, bonnet, boot, 0);
}
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(PlayerToPlayer(playerid,i,7))
{
new enginestatus[4];
if(VEngine[vehicle] == 0) { enginestatus = "Off"; }
else if(VEngine[vehicle] == 1) { enginestatus = "On"; }
new model = GetVehicleModel(vehicleid);
strreplace(pname, '_', ' ');
format(string, sizeof(string), "* %s has turned the engine of his %s %s *", pname, VehicleNames[model - 400], enginestatus);
SendClientMessage(i, COLOR_PURPLE, string);
}
}
}
else return SendClientMessage(playerid, COLOR_WHITE, "You are not driving a vehicle!");
return 1;
}
Stevolas. Help is appreciated.
EDIT: Felt I should include some more information
pawn Код:
new VEngine[MAX_VEHICLES], VLights[MAX_VEHICLES]; //Global variable at top of script
//Under on vehicle spawn
VEngine[vehicleid] = 0;
VLights[vehicleid] = 0;