Guten Tag,
Ich habe folgendes Problem.
-> Ich erstelle einen ATM Funktioniert und kann den auch danach bedienen.
-> Lösche ich einen ATM und erstelle danach einen Neuen funktioniert dies nicht mehr.
-> Darum wollte ich nun wissen was daran falsch ist.
Erstellen:
Code
ocmd:create(playerid, params[])
{
if(Spieler[playerid][pAdmin] < 5)return SendClientMessage(playerid, COLOR_WHITE, ERROR_ADMIN);
new str[32], query[1024];
if(sscanf(params, "s[32]", str))return SendClientMessage(playerid, COLOR_WHITE, "{3592D7}* Benutze {00CC00}/create [Bankautomat]");
if(strcmp(str, "Bankautomat", true) == 0)
{
if(atms >= MAX_ATMS) return SendClientMessage(playerid, COLOR_WHITE, ERROR_MAX_ATM);
new Float:pX, Float:pY, Float:pZ;
GetPlayerPos(playerid, pX, pY, pZ);
CreatedATM[playerid] = CreateObject(19324, pX+2, pY, pZ-1, 0.0, 0.0, 0.0);
EditObject(playerid, CreatedATM[playerid]);
SendClientMessage(playerid, COLOR_WHITE, "{FFFF00}Du kannst nun die Rotation und die Position des {15951F}ATM´s {FFFF00}festlegen.");
return 1;
}
return 1;
}
Alles anzeigen
Wen man den ATM Erstellt hat. Bewegen Speichern usw...
Code
public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
{
new secondQuery[512];
new Float:oldX, Float:oldY, Float:oldZ, Float:oldRotX, Float:oldRotY, Float:oldRotZ;
GetObjectPos(objectid, oldX, oldY, oldZ);
GetObjectRot(objectid, oldRotX, oldRotY, oldRotZ);
if(response == EDIT_RESPONSE_FINAL)
{
if(CreatedATM[playerid] == objectid)
{
new atmid = lastatmid+1;
SetObjectPos(CreatedATM[playerid], fX, fY, fZ);
SetObjectRot(CreatedATM[playerid], fRotX, fRotY, fRotZ);
atmInfo[atmid][ID] = atmid;
atmInfo[atmid][aPickupX] = fX;
atmInfo[atmid][aPickupY] = fY;
atmInfo[atmid][aPickupZ] = fZ;
atmInfo[atmid][aPickuprX] = fRotX;
atmInfo[atmid][aPickuprY] = fRotY;
atmInfo[atmid][aPickuprZ] = fRotZ;
atmInfo[atmid][Exists] = true;
atmInfo[atmid][ObjectID] = CreatedATM[playerid];
mysql_format(MySqlConnection, secondQuery,sizeof(secondQuery),"INSERT INTO `server_atm` (ObjectX, ObjectY, ObjectZ, ObjectrX, ObjectrY, ObjectrZ, CreatedBy) VALUES (%f, %f, %f, %f, %f, %f, '%s')", fX, fY, fZ, fRotX, fRotY, fRotZ, GetName(playerid));
mysql_function_query(MySqlConnection, secondQuery, false, "", "");
atmInfo[atmid][Object3D] = Create3DTextLabel("{F3FF02}Du kannst den Geldautomaten\nmit der Entertaste verwenden.", COLOR_WHITE, atmInfo[atmid][aPickupX], atmInfo[atmid][aPickupY], atmInfo[atmid][aPickupZ]+0.15, 10.0, 0, 0);
format(secondQuery,sizeof(secondQuery),"{FFFF00}Du hast den ATM mit der ID {15951F}%i {FFFF00}erstellt.", atmid);
SendClientMessage(playerid, COLOR_WHITE, secondQuery);
atms++;
lastatmid = atmid;
CreatedATM[playerid] = -1;
}
else if(atmInfo[EditedATM[playerid]][ObjectID] == objectid)
{
new atmid = EditedATM[playerid];
atmInfo[atmid][aPickupX] = fX;
atmInfo[atmid][aPickupY] = fY;
atmInfo[atmid][aPickupZ] = fZ;
atmInfo[atmid][aPickuprX] = fRotX;
atmInfo[atmid][aPickuprY] = fRotY;
atmInfo[atmid][aPickuprZ] = fRotZ;
DestroyObject(atmInfo[atmid][ObjectID]);
Delete3DTextLabel(atmInfo[atmid][Object3D]);
atmInfo[atmid][ObjectID] = CreateObject(19324, atmInfo[atmid][aPickupX], atmInfo[atmid][aPickupY], atmInfo[atmid][aPickupZ], atmInfo[atmid][aPickuprX], atmInfo[atmid][aPickuprY], atmInfo[atmid][aPickuprZ]);
atmInfo[atmid][Object3D] = Create3DTextLabel("{F3FF02}Du kannst den Geldautomaten\nmit der Entertaste verwenden.", COLOR_WHITE, atmInfo[atmid][aPickupX], atmInfo[atmid][aPickupY], atmInfo[atmid][aPickupZ]+0.15, 10.0, 0, 0);
mysql_format(MySqlConnection, secondQuery,sizeof(secondQuery),"UPDATE `server_atm` SET ObjectX = '%f', ObjectY = '%f', ObjectZ = '%f', ObjectrX = '%f', ObjectrY = '%f', ObjectrZ = '%f' WHERE ID = '%d'", fX, fY, fZ, fRotX, fRotY, fRotZ, atmid);
mysql_function_query(MySqlConnection, secondQuery, false, "", "");
format(secondQuery,sizeof(secondQuery),"{FFFF00}Du hast den ATM mit der ID {15951F}%i {FFFF00}erfolgreich bearbeitet.", atmid);
SendClientMessage(playerid, COLOR_WHITE, secondQuery);
}
}
if(response == EDIT_RESPONSE_CANCEL)
{
if(CreatedATM[playerid] == objectid)
{
DestroyObject(CreatedATM[playerid]);
CreatedATM[playerid] = -1;
SendClientMessage(playerid, COLOR_WHITE, "{FFFF00}Du hast die Bearbeitung abgebrochen. Der {15951F}ATM {FFFF00}wurde nicht gespeichert.");
}
if(atmInfo[EditedATM[playerid]][ObjectID] == objectid)
{
SetObjectPos(objectid, oldX, oldY, oldZ);
SetObjectRot(objectid, oldRotX, oldRotY, oldRotZ);
SendClientMessage(playerid, COLOR_WHITE, "{FFFF00}Du hast die Bearbeitung abgebrochen. Der {15951F}ATM {FFFF00}wurde nicht gespeichert.");
}
}
return 0;
}
Alles anzeigen
Löschen:
Code
ocmd:delete(playerid, params[])
{
if(Spieler[playerid][pAdmin] < 5)return SendClientMessage(playerid, COLOR_WHITE, ERROR_ADMIN);
new id, string[128], query[128], cmd[15];
if(sscanf(params, "s[15]i", cmd, id))return SendClientMessage(playerid, COLOR_WHITE, "{3592D7}* Benutze {00CC00}/delete [Bankautomat] [ID]");
if(strcmp(cmd, "Bankautomat", true) == 0)
{
if(!atmInfo[id][Exists]) return SendClientMessage(playerid, COLOR_WHITE, ERROR_ATM);
mysql_format(MySqlConnection, query,sizeof(query),"DELETE FROM `server_atm` WHERE ID = '%d'", id);
mysql_function_query(MySqlConnection, query, false, "", "");
DestroyObject(atmInfo[id][ObjectID]);
Delete3DTextLabel(atmInfo[id][Object3D]);
atmInfo[id][ID] = -1;
atmInfo[id][ObjectID] = -1;
atmInfo[id][aPickupX] = 0.0;
atmInfo[id][aPickupY] = 0.0;
atmInfo[id][aPickupZ] = 0.0;
atmInfo[id][aPickuprX] = 0.0;
atmInfo[id][aPickuprY] = 0.0;
atmInfo[id][aPickuprZ] = 0.0;
atmInfo[id][Exists] = false;
format(atmInfo[id][CreatedBy], MAX_PLAYER_NAME,"");
atms--;
format(query, sizeof(query), "{FFFF00}%s {15951F}%s {FFFF00}hat einen ATM mit der ID {15951F}%d {FFFF00}gelöscht!", GetPlayerAdminName(playerid), GetName(playerid), id);
SendAdminMessage(COLOR_WHITE, query);
}
return 1;
}
Alles anzeigen