13.08.2011, 17:47
Quote:
if(strcmp(cmd, "/spawncar", true) == 0) { if(IsPlayerConnected(playerid)) { if (PlayerInfo[playerid][pAdmin] < 3) { SendClientMessage(playerid, COLOR_GREY, "[Error:] You are not authorized to use that command"); return 1; } tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "[Usage:] /spawncar [carid] [color1] [color2]"); return 1; } new car; car = strval(tmp); if(car < 400 || car > 611) { SendClientMessage(playerid, COLOR_GREY, "[Error:] Vehicle ID can not be below 400 or above 611"); return 1; } tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "[Usage:] /spawncar [carid] [color1] [color2]"); return 1; } new color1; color1 = strval(tmp); if(color1 < 0 || color1 > 126) { SendClientMessage(playerid, COLOR_GREY, "[Error:] Color ID can not be below 0 or above 126"); return 1; } tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "[Usage:] /spawncar [carid] [color1] [color2]"); return 1; } new color2; color2 = strval(tmp); if(color2 < 0 || color2 > 126) { SendClientMessage(playerid, COLOR_GREY, "[Error:] Color ID can not be below 0 or above 126"); return 1; } new FloatcX,FloatcY,FloatcZ; GetPlayerPos(playerid, scX,scY,scZ); new id = CreateVehicle(car, scX,scY,scZ, 0.0, color1, color2, 60000); CreatedCars[CreatedCar] = id; CreatedCar ++; format(string, sizeof(string), "[Info:] Vehicle %d spawned", id); SendClientMessage(playerid, COLOR_ADMINCMD, string); } return 1; } |
Also, I've noted a few problems.
The vehicle does not save.
The /engine command turns the engine off before one.
The speedometer does not display.
The vehicle cannot be set to a faction etc as it is not saved.
This is the variables of the dynamic system.
CreateVehicle(DynamicCars[id][CarModel],DynamicCars[id][CarX],DynamicCars[id][CarY],DynamicCars[id][CarZ],DynamicCars[id][CarAngle],DynamicCars[id][CarColor1],DynamicCars[id][CarColor2], -1);
Note: there is a SaveDynamicCars(); function, but it doesnt work for /spawncar.