CMD:veh(playerid, params[])
{
new car;
new string[128];
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
if(sscanf(params,"i", car)) return SendClientMessage(playerid,0xff0000ff,"USAGE: /Veh <Vehicle ID 400 - 611>");
else if(car < 400 || car >611) return SendClientMessage(playerid, 0xff0000ff, "ERROR: Cannot go under 400 or above 611.");
{
if(Vehicle[playerid] != 0)
{
DestroyVehicle(Vehicle[playerid]);
}
Vehicle[playerid] = CreateVehicle(car, X, Y, Z + 2.0, 0, -1, -1, 1);
format(string,sizeof(string),"You Have Spawned Vehicle ID %i",car);
SendClientMessage(playerid, 0xffffffff, string);
PutPlayerInVehicle(playerid, Vehicle[playerid], 0);
}
return 1;
}
new Vehicle[MAX_PLAYERS];
CMD:veh(playerid, params[])
{
if(PlayerInfo[playerid][AdminLevel] >= 4)
{
new Vehicle[50];
if(!sscanf(params, "s[50]", Vehicle))
{
new string[128], Float:Pos[4];
GetPlayerPos(playerid, Pos[0],Pos[1],Pos[2]);
GetPlayerFacingAngle(playerid, Pos[3]);
new veh = GetVehicleModelID(Vehicle);
if(veh < 400 || veh > 611) return SendClientMessage(playerid, GREY, "That wasn't a valid vehicle name.");
if(!IsPlayerInAnyVehicle(playerid))
{
new vehicleid = CreateVehicle(veh, Pos[0], Pos[1], Pos[2], Pos[3], -1, -1, -1);
PutPlayerInVehicle(playerid, vehicleid, 0);
format(string, sizeof(string), "AdmCmd: %s has just spawned a %s (VID: %d)", RemoveUnderScore(playerid), GetVehicleName(GetPlayerVehicleID(playerid)), GetPlayerVehicleID(playerid));
SendAdminMessage(RED, string);
}
else return SendClientMessage(playerid, GREY, "You mustn't be in a vehicle to use this command.");
}
else return SendClientMessage(playerid, GREY, "Usage: /veh [vehiclename]");
}
else return SendClientMessage(playerid, GREY, AdminOnly);
return 1;
}
if(Vehicle[playerid] != 0)
!= INVALID_VEHICLEID What if the ID of it is 0? Do the same under OnPlayerDisconnect: if(Vehicle[playerid] != INVALID_PLAYER_ID) DestroyVehicle(Vehicle[playerid]); If it continues to have issues, I will test it in my script and resolve the issue. |
At the end, none of the commands worked. The same happened to every of them. It says the vehicle has been spawned but the vehicle is not there.
|
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/tottalcar", cmdtext, true) == 0)
{
new
num
;
for (new v = GetVehiclePoolSize(); v >= 1; --v) {
if (GetVehicleModel(v) >= 400 && GetVehicleModel(v) <= 611) num++;
}
new
msg[128]
;
format(msg, sizeof(msg), "Total of %d vehicles server", num);
SendClientMessange(playerid, 0xFF0000FF, msg);
return true;
}
return false;
}
CMD:veh(playerid, params[]) { new car, Float:CarPos[3], string[32]; if(sscanf(params,"d", car)) return SendClientMessage(playerid,0xff0000ff,"USAGE: /Veh <Vehicle ID 400 - 611>"); if(car < 400 || car > 611) return SendClientMessage(playerid, 0xff0000ff, "ERROR: Cannot go under 400 or above 611."); if(GetPlayerInterior(playerid) != 0) return 1; GetPlayerPos(playerid, CarPos[0], CarPos[1], CarPos[2]); DestroyVehicle(Vehicle[playerid]); Vehicle[playerid] = CreateVehicle(car, CarPos[0], CarPos[1], CarPos[2] + 2.0, 0, -1, -1, 1); SetVehicleVirtualWorld(Vehicle[playerid], GetPlayerVirtualWorld(playerid)); PutPlayerInVehicle(playerid, Vehicle[playerid], 0); format(string,sizeof(string),"You Have Spawned Vehicle ID %i",car); SendClientMessage(playerid, 0xffffffff, string); return 1; }
Try this way:
Код:
CMD:veh(playerid, params[]) { new car, Float:CarPos[3], string[32]; if(sscanf(params,"d", car)) return SendClientMessage(playerid,0xff0000ff,"USAGE: /Veh <Vehicle ID 400 - 611>"); if(car < 400 || car > 611) return SendClientMessage(playerid, 0xff0000ff, "ERROR: Cannot go under 400 or above 611."); if(GetPlayerInterior(playerid) != 0) return 1; GetPlayerPos(playerid, CarPos[0], CarPos[1], CarPos[2]); DestroyVehicle(Vehicle[playerid]); Vehicle[playerid] = CreateVehicle(car, CarPos[0], CarPos[1], CarPos[2] + 2.0, 0, -1, -1, 1); SetVehicleVirtualWorld(Vehicle[playerid], GetPlayerVirtualWorld(playerid)); PutPlayerInVehicle(playerid, Vehicle[playerid], 0); format(string,sizeof(string),"You Have Spawned Vehicle ID %i",car); SendClientMessage(playerid, 0xffffffff, string); return 1; } |
COMMAND:vc(playerid, params[]) { if(playerData[playerid][playerLoggedIn]) { if(playerData[playerid][playerLevel] >= 3) { new message[128], vehName[16], vehID, Float:jX, Float:jY, Float:jZ, Float:jA; if(!sscanf(params, "s[16]", vehName)) { vehID = getVehicleModelFromName(vehName); if(vehID < 400 || vehID > 612) { SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}Unknown vehicle name provided!"); } else { GetPlayerFacingAngle(playerid, jA); GetPlayerPos(playerid, jX, jY, jZ); if(vehID == 612) { if(playerData[playerid][playerLevel] >= 6) { SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USEJETPACK); } else { SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}Due to the anti-cheat method this server uses, you're unable to spawn a jetpack."); } } else { for(new v = 0; v < MAX_ADMIN_SPAWNED_VEHICLES; v++) { if(!adminSpawnedVehicles[v]) { adminSpawnedVehicles[v] = CreateVehicle(vehID, jX, jY, jZ, jA, random(255), random(255), 120); LinkVehicleToInterior(adminSpawnedVehicles[v], GetPlayerInterior(playerid)); SetVehicleVirtualWorld(adminSpawnedVehicles[v], GetPlayerVirtualWorld(playerid)); ac_PutPlayerInVehicle(playerid, adminSpawnedVehicles[v], 0); format(message, sizeof(message), "{02FBF2}[ADMIN] {FFFFFF}You have spawned a %s", vehicleNames[vehID - 400]); SendClientMessage(playerid, COLOR_WHITE, message); break; } if(v == (MAX_ADMIN_SPAWNED_VEHICLES - 1)) { SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}Too many administrator vehicles have been spawned, remove some before trying again."); } } } } } else { SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}Usage: \"vc <vehicle name>\""); } } else { return 0; } } else { SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You must be logged in to use commands."); } return 1; }