08.01.2012, 06:14
I'm having the same problem with a different code.
I've got ZCMD and everything, but when I compile this, PAWN crashes.
And I actually made this using a tutorial, and I know how it works...
command(startengine, playerid, params[])
{
if(GetPlayerState(playerid) == 2) //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.
if(Engine[vehicle] == 0) //This is checking if the engine of the vehicle, is turned off or not.
{
new engine,lights,alarm,doors,bonnet,boot,objective; //This is defining the vehicles current items.
GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);//This is checking the vehicle's engine/lights/alarm/doors/bonnet/boot/objective status.
Engine[vehicle] = 1; //This is setting the global variable that you created at the beginning.
SetVehicleParamsEx(vehicle, 1, lights, alarm, doors, bonnet, boot, 0); //This is setting the vehicles engine to be on.
}
}
else return SendClientMessage(playerid, GREY, "This vehicles engine is already turned on.");
return 1;
}
command(stopengine, playerid, params[])//This bit is creating the command
{
#pragma unused params
if(GetPlayerState(playerid) == 2) //This bit is checking the players seat
{
new vehicle = GetPlayerVehicleID(playerid);
if(Engine[vehicle] == 1)
{
new engine,lights,alarm,doors,bonnet,boot,objective; //Same procedure, this is defining the variables
Engine[vehicle] = 0; //This bit here, is quite vital. because if you left it at: Engine[vehicle] = 0; Then the vehicle would turn off, then not start again unless respawned.
GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);//This bit is checking the current status of the vehicles.
SetVehicleParamsEx(vehicle, 0, lights, alarm, doors, bonnet, boot, 0);//This bit is setting the engine to be turned off.
}
else return SendClientMessage(playerid, GREY, "This vehicle's engine is already off.");//This will display on the screen if the engine is already off.
}
else return SendClientMessage(playerid, GREY, "You must be in the drivers seat of a vehicle.");//This message will display on the screen if the player doing the command isn't in the drivers seat of a vehicle
return 1;
}
I've got ZCMD and everything, but when I compile this, PAWN crashes.
And I actually made this using a tutorial, and I know how it works...
command(startengine, playerid, params[])
{
if(GetPlayerState(playerid) == 2) //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.
if(Engine[vehicle] == 0) //This is checking if the engine of the vehicle, is turned off or not.
{
new engine,lights,alarm,doors,bonnet,boot,objective; //This is defining the vehicles current items.
GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);//This is checking the vehicle's engine/lights/alarm/doors/bonnet/boot/objective status.
Engine[vehicle] = 1; //This is setting the global variable that you created at the beginning.
SetVehicleParamsEx(vehicle, 1, lights, alarm, doors, bonnet, boot, 0); //This is setting the vehicles engine to be on.
}
}
else return SendClientMessage(playerid, GREY, "This vehicles engine is already turned on.");
return 1;
}
command(stopengine, playerid, params[])//This bit is creating the command
{
#pragma unused params
if(GetPlayerState(playerid) == 2) //This bit is checking the players seat
{
new vehicle = GetPlayerVehicleID(playerid);
if(Engine[vehicle] == 1)
{
new engine,lights,alarm,doors,bonnet,boot,objective; //Same procedure, this is defining the variables
Engine[vehicle] = 0; //This bit here, is quite vital. because if you left it at: Engine[vehicle] = 0; Then the vehicle would turn off, then not start again unless respawned.
GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);//This bit is checking the current status of the vehicles.
SetVehicleParamsEx(vehicle, 0, lights, alarm, doors, bonnet, boot, 0);//This bit is setting the engine to be turned off.
}
else return SendClientMessage(playerid, GREY, "This vehicle's engine is already off.");//This will display on the screen if the engine is already off.
}
else return SendClientMessage(playerid, GREY, "You must be in the drivers seat of a vehicle.");//This message will display on the screen if the player doing the command isn't in the drivers seat of a vehicle
return 1;
}