Den Befehl
Code
ocmd:createcardealer(playerid,params[])
{
new name[32],price,level,Float:xPos[3];
if(pInfo[playerid][pAdmin] != 5)return 1;
if(sscanf(params,"dds[32]",price,level,name))return SendClientMessage(playerid,COLOR_GREY,"Benutze: /createcardealer [Preis] [Level] [Name]");
for(new i;i<MAX_AUTOHAUS;i++) {
if(AHInfo[i][zCreated])continue;
new str[256];
GetPlayerPos(playerid,xPos[0],xPos[1],xPos[2]);
format(str,sizeof str,"INSERT INTO `Cardealers` (`Owner`, `PosX`, `PosY`, `PosZ`, `Name`, `Price`, `Level`, `LPosX`, `LPosY`, `LPosZ`) VALUES ('Niemand', '%f', '%f', '%f', '%s', '%d', '%d', '%f', '%f', '%f')",xPos[0],xPos[1],xPos[2],name,price,level,xPos[0],xPos[1],xPos[2]);
mysql_query(str);
KillCarDealer(i);
LoadCarDealer(i);
}
return 1;
}
Alles anzeigen
kann ich einmal InGame eingeben. Danach wird er erstellt allerdings aber 1000 fach. Was habe ich da falsch gemacht ?
Code
stock KillCarDealer(id)
{
SaveCarDealer(id);
DestroyPickup(AHInfo[id][zPickup]);
Delete3DTextLabel(AHInfo[id][zLabel]);
AHInfo[id][zCreated] = false;
return 1;
}
Code
stock SaveCarDealer(id)
{
new query[512];
format(query,sizeof query,"UPDATE `Cardealers` SET `Owner` = '%s', `Name` = '%s', `Bank` = '%d', `OrderCap` = '%d', `StoreCap` = '%d', `LPosX` = '%f', `LPosY` = '%f', `LPosZ` = '%f' WHERE `ID` = '%d'",AHInfo[id][zOwner],AHInfo[id][zName],AHInfo[id][zBank],AHInfo[id][zOrderCap],AHInfo[id][zStoreCap],AHInfo[id][zLPosX],AHInfo[id][zLPosY],AHInfo[id][zLPosZ],AHInfo[id][zID]);
mysql_query(query);
return 1;
}