if(strcmp(cmd, "/findcar", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(gPlayerHasCar[playerid] == 1)
{
new Float:vx, Float:vy, Float:vz;
GetVehiclePos(Vehicle[playerid], vx, vy, vz);
SetPlayerCheckpoint(playerid, vx, vy, vz, 10.0);
Checkpoint[playerid] = 1;
SendClientMessage(playerid, 0xFFFFFFAA, "Go to the checkpoint to find your car!");
return 1;
}
else {
SendClientMessage(playerid, 0xAFAFAFAA, "You don't own a vehicle.");
return 1;
}
}
Are you sure you posted the correct code?
What should this /engine command do? You should really reconsider not using ZCMD or Y_CMD or any other command processor. Using strcmp under OnPlayerCommandText is slow. |
YCMD:engine(playerid,params[],help)
{
if(!IsPlayerInAnyVehicle(playerid)) return GameTextForPlayer(playerid,"error",3000,3);
new bool:stmt[7];
GetVehicleParamsEx(GetPlayerVehicleID(playerid),stmt[0],stmt[1],stmt[2],stmt[3],stmt[4],stmt[5],stmt[6]);
SetVehicleParamsEx(GetPlayerVehicleID(playerid),stmt[0]=stmt[0]?false:true,stmt[1],stmt[2],stmt[3],stmt[4],stmt[5],stmt[6]);
return 1;
}
The .amx size after compile is 726 bytes. Nothing much, but as you can see we're using 32-bit variables for only 0 and 1, so that's a waste of a lot memory. The most relevant bit type in this case would be 1-bit
|
if(!strcmp(cmdtext,"/engine",true,7))
{
new vehicleid = GetPlayerVehicleID(playerid);
if(!vehicleid) return SendClientMessage(playerid,0xFF0000FF,"You must be in a vehicle!");
// You might want to add an exception to vehicles without an engine, for example bikes.
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(engine != VEHICLE_PARAMS_ON)
{
SetVehicleParamsEx(vehicleid, VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
SendClientMessage(playerid,0x00FF00FF,"The engine is now running");
}
else
{
SetVehicleParamsEx(vehicleid, VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
SendClientMessage(playerid,0x00FF00FF,"The engine is stopped");
}
}