07.10.2012, 11:51
purpose is to add cars through a command when you are on the server as admin
This is the command that is in gamemode
Code:
if(strcmp(cmd, "/createcar", true) == 0) { if(IsPlayerConnected(playerid)) { if(PlayerData[playerid][pAdmin] < 6) { SendError(playerid,cmd); return 1; } new PlayerName[MAX_PLAYER_NAME]; GetPlayerName(playerid, PlayerName, sizeof(PlayerName)); if(EsteManager(playerid))//omg, { if(CreatedCar != 0)// { SendClientMessage(playerid, COLOR_GRAD1, "You can create a personal car before resart (reason /veh)"); return 1; } tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendUsage(playerid,"/createcar [model] [value]"); return 1; } new model = strval(tmp); tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendUsage(playerid,"/createcar [model] [value]"); return 1; } new value = strval(tmp); new Float:x1,Float:y1,Float:z1; GetPlayerPos(playerid,x1,y1,z1); if(model < 400 || model > 611) { return 1; } for(new i=1;i<=sizeof(CarData);i++) { if(CarData[i][cModel] == 0) { CarData[i][cModel] = model; CarData[i][cValue] = value; CarData[i][cLocationx] = x1; CarData[i][cLocationy] = y1; CarData[i][cLocationz] = z1; CarData[i][cOwned] = 0; AddStaticVehicle(model,x1,y1,z1,0,0,0); format(string, sizeof(string), "%s.",ArIsim[model-400]); strmid(CarData[i][cDescription], string, 0, strlen(string), 255); new idd; mysql_query("SELECT * FROM `cars`"); mysql_store_result(); idd = mysql_num_rows()+1; mysql_free_result(); format(string, sizeof(string),"INSERT INTO `cars` (`'id`, `Model`, `Locationx`, `Locationy`, `Locationz`, `Description`, `Value`, `Owned`)\ VALUES ('%d', '%d', '%f', '%f', '%f', '%s', '%d', '%d'", idd, CarData[i][cModel], CarData[i][cLocationx], CarData[i][cLocationy], CarData[i][cLocationz], CarData[i][cDescription], CarData[i][cValue], CarData[i][cOwned]); mysql_query(string); SendClientMessage(playerid,COLOR_WHITE,"The car was successfully created!"); return 1; } } } } return 1; }