COMMAND:engine(playerid, params[])
{
new xr = GetPlayerVehicleID(playerid);
new car = GetPlayerNearestVehicle(playerid);
new vehicleid = GetPlayerNearestVehicle(playerid);
new engine,lights,alarm,doors,bonnet,boot,objective;
new sender[MAX_STRING];
//Vehicles[GetPlayerVehicleID(playerid)][carteam] != CIV
if(PlayerTemp[playerid][hname]==1) myStrcpy(sender,"Stranger");
else myStrcpy(sender,NameEx(playerid));
if(IsPlayerInAnyVehicle(playerid) && Vehicles[xr][carmodel] == 481 && Vehicles[xr][carmodel] == 509) return SendClientError(playerid, "You are not in any vehicle, or there is no engine implented.");
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientError(playerid, "You are not in any vehicle!");
new State;
State = GetPlayerState(playerid);
if(State!=PLAYER_STATE_DRIVER) return SendClientMessage(playerid,COLOR_GREY,"You are not the driver!");
new stringa[MAX_STRING];
new vid = GetPlayerVehicleID(playerid);
if(Vehicles[GetPlayerVehicleID(playerid)][carteam] == CIV && strcmp(PlayerInfo[playerid][playerteam],Vehicles[GetPlayerVehicleID(playerid)][carteam],false) && strcmp(PlayerName(playerid),Vehicles[vehicleid][carowner],false) && strcmp(PlayerName(playerid),Vehicles[vehicleid][dupekey],false))
{
return SendClientError(playerid, "You don't have the authority to use this vehicle or you don't have the dupe keys!");
}
if(engine == 0)
{
SetVehicleParamsEx(vid, 1, lights, alarm, doors, bonnet, boot, objective);
format(stringa,sizeof(stringa),"%s has turns on the engine of the %s.",sender,GetVehicleName(car));
NearMessage(playerid,stringa,COLOR_ME2);
TogglePlayerControllable(playerid, true);
}
else
{
SetVehicleParamsEx(vid, 0, lights, alarm, doors, bonnet, boot, objective);
format(stringa,sizeof(stringa),"%s has turns off the engine of the %s.",sender,GetVehicleName(car));
NearMessage(playerid,stringa,COLOR_ME2);
TogglePlayerControllable(playerid, true);
}
}
return 1;
}
COMMAND:engine(playerid, params[]) { new xr = GetPlayerVehicleID(playerid); new car = GetPlayerNearestVehicle(playerid); new vehicleid = GetPlayerNearestVehicle(playerid); new engine,lights,alarm,doors,bonnet,boot,objective; new sender[MAX_STRING]; //Vehicles[GetPlayerVehicleID(playerid)][carteam] != CIV if(PlayerTemp[playerid][hname]==1) myStrcpy(sender,"Stranger"); else myStrcpy(sender,NameEx(playerid)); if(IsPlayerInAnyVehicle(playerid) && Vehicles[xr][carmodel] == 481 && Vehicles[xr][carmodel] == 509) return SendClientError(playerid, "You are not in any vehicle, or there is no engine implented."); { if(!IsPlayerInAnyVehicle(playerid)) return SendClientError(playerid, "You are not in any vehicle!"); new State; State = GetPlayerState(playerid); if(State!=PLAYER_STATE_DRIVER) return SendClientMessage(playerid,COLOR_GREY,"You are not the driver!"); new stringa[MAX_STRING]; new vid = GetPlayerVehicleID(playerid); if(Vehicles[GetPlayerVehicleID(playerid)][carteam] == CIV && strcmp(PlayerInfo[playerid][playerteam],Vehicles[GetPlayerVehicleID(playerid)][carteam],false) && strcmp(PlayerName(playerid),Vehicles[vehicleid][carowner],false) && strcmp(PlayerName(playerid),Vehicles[vehicleid][dupekey],false)) { return SendClientError(playerid, "You don't have the authority to use this vehicle or you don't have the dupe keys!"); } GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective); if(engine == 0) { SetVehicleParamsEx(vid, 1, lights, alarm, doors, bonnet, boot, objective); format(stringa,sizeof(stringa),"%s has turns on the engine of the %s.",sender,GetVehicleName(car)); NearMessage(playerid,stringa,COLOR_ME2); TogglePlayerControllable(playerid, true); } else { SetVehicleParamsEx(vid, 0, lights, alarm, doors, bonnet, boot, objective); format(stringa,sizeof(stringa),"%s has turns off the engine of the %s.",sender,GetVehicleName(car)); NearMessage(playerid,stringa,COLOR_ME2); TogglePlayerControllable(playerid, true); } } return 1; }
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
Why do you get the nearest vehicle, and then check if they are in the vehicle, and then deny if they aren't in a vehicle
You've got to have SO many errors from that code.... |
COMMAND:engine(playerid, params[])
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientError(playerid, "You are not in any vehicle!"); //Checking for if we even need to do anything at all in the first instance.
new vehicleid = GetPlayerVehicleID(playerid); //Getting VehicleID once
if(Vehicles[vehicleid][carmodel] == 481 || Vehicles[vehicleid][carmodel] == 509) return SendClientError(playerid, "There is no engine in this vehicle."); //Checking for the engine now that we know they are in a car
new sender[MAX_PLAYER_NAME]; //This only actually needs to be 24 or so long, it's not needing to be MAX_STRING, which if that is 255, then that is SOOOO old, MAX_STRING should be around 144. (That's all a line of text can display in the client chat)
if(PlayerTemp[playerid][hname]==1) myStrcpy(sender,"Stranger"); // Assigning the name to the player.
else myStrcpy(sender,NameEx(playerid)); // If you use this a lot, you could look at making a global variable for this to use throughout your script. (pAlias for instance and make that do it on the command that selects what they have, and OnPlayerConnect.
new engine,lights,alarm,doors,bonnet,boot,objective;
//Vehicles[GetPlayerVehicleID(playerid)][carteam] != CIV
if(GetPlayerState(playerid)!=PLAYER_STATE_DRIVER) return SendClientMessage(playerid,COLOR_GREY,"You are not the driver!"); // Checking they are the driver
new stringa[MAX_STRING];
if(Vehicles[vehicleid][carteam] == CIV && strcmp(PlayerInfo[playerid][playerteam],Vehicles[vehicleid][carteam],false) && strcmp(PlayerName(playerid),Vehicles[vehicleid][carowner],false) && strcmp(PlayerName(playerid),Vehicles[vehicleid][dupekey],false))
{
return SendClientError(playerid, "You don't have the authority to use this vehicle or you don't have the dupe keys!");
}
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(engine == 0)
{
SetVehicleParamsEx(vehicleid, 1, lights, alarm, doors, bonnet, boot, objective);
format(stringa,sizeof(stringa),"%s has turns on the engine of the %s.",sender,GetVehicleName(car));
NearMessage(playerid,stringa,COLOR_ME2);
}
else
{
SetVehicleParamsEx(vehicleid, 0, lights, alarm, doors, bonnet, boot, objective);
format(stringa,sizeof(stringa),"%s has turns off the engine of the %s.",sender,GetVehicleName(car));
NearMessage(playerid,stringa,COLOR_ME2);
}
return 1;
}