Ich hab ein Problem mit mein atm bank Script wenn ich auf abrechen drücke werde ich automatisch geckickt
#include <a_samp>
#include <dini>
#define MAX_ATMS 20
#define DIALOG_BANK 1
#define DIALOG_EINZAHLEN 2
#define DIALOG_ABHEBEN 3
#define DIALOG_NEWMONEY 4
#define DIALOG_UBERWEISEN 5
#define DIALOG_UBERWEISUNG 6
#define COLOR_WHITE 0xFFFFFFFF
#define COLOR_GREY 0xAFAFAFAA
enum Bank
{
Float:atmx,
Float:atmy,
Float:atmz,
}
new position[MAX_ATMS][Bank];
new Betrag[MAX_PLAYERS];
new tmpid[MAX_PLAYERS];
new tmpmoney[MAX_PLAYERS];
AddAtm(atmid, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ)
{
CreateObject(2942, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ, 300.0);
position[atmid][atmx] = Float:X;
position[atmid][atmy] = Float:Y;
position[atmid][atmz] = Float:Z;
}
stock GivePlayerBankCash(playerid, amount)
{
Betrag[playerid] += amount;
return 1;
}
stock SetPlayerBankCash(playerid, amount)
{
Betrag[playerid] = amount;
}
stock GetPlayerBankCash(playerid)
{
return Betrag[playerid];
}
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Banksystem by BRain_storming");
print(" loaded...");
print("--------------------------------------\n");
AddAtm(0, 2280.10424805, 2432.39428711, 10.46321201, 0.00000000, 0.00000000, 0.00000000);
AddAtm(1, 1495.9509277344, -1749.9173583984, 15.088212013245, 0, 0, 180);
AddAtm(2, 1648.8013916016, -1656.0667724609, 22.15852355957, 0, 0, 0);
AddAtm(3, 2128.3308105469, -1771.4370117188, 13.202196121216, 0, 0, 270);
AddAtm(4, 1812.3605957031, -1339.3525390625, 14.702471733093, 0, 0, 90);
AddAtm(5, 1812.0008544922, -1928.3114013672, 13.192024230957, 0, 0, 90);
AddAtm(6, 1633.0314941406, -2335.5925292969, 13.183035850525, 0, 0, 180);
AddAtm(7, 1920.7565917969, -1765.8736572266, 13.189774513245, 0, 0, 182);
AddAtm(8, 365.30261230469, -1764.7429199219, 5.1224308013916, 0, 0, 0);
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerConnect(playerid)
{
new pName[MAX_PLAYER_NAME],userdatei[50];
GetPlayerName(playerid, pName, sizeof(pName));
format(userdatei,sizeof(userdatei),"%s.cash",pName);
if(dini_Exists(userdatei))
{
Betrag[playerid] = dini_Int(userdatei,"cash");
}
else
{
dini_Create(userdatei);
dini_IntSet(userdatei,"cash",0);
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new pName[MAX_PLAYER_NAME],userdatei[50];
GetPlayerName(playerid, pName, sizeof(pName));
format(userdatei,sizeof(userdatei),"%s.cash",pName);
if(dini_Exists(userdatei))
{
dini_IntSet(userdatei,"cash",Betrag[playerid]);
}
Betrag[playerid] = 0;
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/atm", true) == 0)
{
for(new i=0;i<MAX_ATMS;i++)
{
if(IsPlayerInRangeOfPoint(playerid,3.0,position[i][atmx],position[i][atmy],position[i][atmz]))
{
ShowPlayerDialog(playerid, DIALOG_BANK,2,"PR Bankautomat","Abheben\r\nEinzahlen\r\nÜberweisen\r\nKontoauszug","Bestätigen","Abbrechen");
return 1;
}
}
SendClientMessage(playerid, COLOR_GREY,"Kein ATM in der nähe");
return 1;
}
return 0;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(response)
{
switch(dialogid)
{
case DIALOG_BANK:
{
switch(listitem)
{
case 0: ShowPlayerDialog(playerid,DIALOG_ABHEBEN,1,"Abheben","Wie viel Geld willst du abheben?","Bestätigen","Abbrechen");
case 1: ShowPlayerDialog(playerid,DIALOG_EINZAHLEN,1,"Einzahlen","Wie viel Geld willst du einzahlen?","Bestätigen","Abbrechen");
case 2: ShowPlayerDialog(playerid,DIALOG_UBERWEISEN,1,"Überweisen","Wenn möchtest du Geld Überweisen?","Bestätigen","Abbrechen");
case 3:
{
new string[128];
format(string,sizeof(string),"=================================\n\n[Kontostand]: %i$ \n\n=================================",GetPlayerBankCash(playerid));
ShowPlayerDialog(playerid,DIALOG_NEWMONEY,0,"Kontoauszug",string,"Bestätigen","Abbrechen");
}
}
}
case DIALOG_ABHEBEN:
{
if(strval(inputtext) > GetPlayerBankCash(playerid) || strval(inputtext) <= 0)
{
ShowPlayerDialog(playerid,DIALOG_ABHEBEN,1,"Abheben","[ERROR]\nWie viel Geld willst du abheben?","Bestätigen","Abbrechen");
}
else
{
GivePlayerMoney(playerid, strval(inputtext));
GivePlayerBankCash(playerid, -strval(inputtext));
new string[123];
format(string,sizeof(string),"=================================\n\n[Alter Kontostand]: %i$ \n\n[Neuer Kontostand]: %i$ \n\n=================================",GetPlayerBankCash(playerid)+strval(inputtext),GetPlayerBankCash(playerid));
ShowPlayerDialog(playerid,DIALOG_NEWMONEY,0,"Kontoauszug",string,"Bestätigen","Abbrechen");
}
}
case DIALOG_EINZAHLEN:
{
if(strval(inputtext) > GetPlayerMoney(playerid) || strval(inputtext) <= 0)
{
ShowPlayerDialog(playerid,DIALOG_ABHEBEN,1,"Abheben","[ERROR]\nWie viel Geld willst du abheben?","Bestätigen","Abbrechen");
}
else
{
GivePlayerMoney(playerid, -strval(inputtext));
GivePlayerBankCash(playerid, strval(inputtext));
new string[123];
format(string,sizeof(string),"=================================\n\n[Alter Kontostand]: %i$ \n\n[Neuer Kontostand]: %i$ \n\n=================================",GetPlayerBankCash(playerid)-strval(inputtext),GetPlayerBankCash(playerid));
ShowPlayerDialog(playerid,DIALOG_NEWMONEY,0,"Kontoauszug",string,"Bestätigen","Abbrechen");
}
}
case DIALOG_NEWMONEY:
{
ShowPlayerDialog(playerid, DIALOG_BANK,2,"BRain's Bank","Abheben\r\nEinzahlen\r\nÜberweisen\r\nKontoauszug","Bestätigen","Abbrechen");
}
case DIALOG_UBERWEISEN:
{
if(IsNumeric(inputtext))
{
if(strval(inputtext) == playerid)
{
ShowPlayerDialog(playerid,DIALOG_UBERWEISEN,1,"Überweisen","[ERROR]\nWenn möchtest du Geld Überweisen?","Bestätigen","Abbrechen");
return 1;
}
if(IsPlayerConnected(strval(inputtext)))
{
tmpid[playerid] = strval(inputtext);
tmpmoney[playerid] = strval(inputtext);
ShowPlayerDialog(playerid,DIALOG_UBERWEISUNG,1,"Überweisen","Wie viel möchtest du Überweisen?","Bestätigen","Abbrechen");
}
else
{
ShowPlayerDialog(playerid,DIALOG_UBERWEISEN,1,"Überweisen","[ERROR]\nWenn möchtest du Geld Überweisen?","Bestätigen","Abbrechen");
}
}
else
{
new pID = GetPlayerId(inputtext);
if(pID == playerid)
{
ShowPlayerDialog(playerid,DIALOG_UBERWEISEN,1,"Überweisen","[ERROR]\nWenn möchtest du Geld Überweisen?","Bestätigen","Abbrechen");
return 1;
}
if(IsPlayerConnected(pID))
{
tmpid[playerid] = pID;
tmpmoney[playerid] = strval(inputtext);
ShowPlayerDialog(playerid,DIALOG_UBERWEISUNG,1,"Überweisen","Wie viel möchtest du Überweisen?","Bestätigen","Abbrechen");
}
else
{
ShowPlayerDialog(playerid,DIALOG_UBERWEISEN,1,"Überweisen","[ERROR]\nWenn möchtest du Geld Überweisen?","Bestätigen","Abbrechen");
}
}
}
case DIALOG_UBERWEISUNG:
{
if(GetPlayerBankCash(playerid) < strval(inputtext) || strval(inputtext) <= 0)
{
ShowPlayerDialog(playerid,DIALOG_UBERWEISUNG,1,"Überweisen","[ERROR]\nWie viel möchtest du Überweisen?","Bestätigen","Abbrechen");
}
else
{
GivePlayerBankCash(playerid, -strval(inputtext));
GivePlayerBankCash(tmpid[playerid], strval(inputtext));
new string[123], string2[123],string3[123], name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME];
format(string,sizeof(string),"=================================\n\n[Alter Kontostand]: %i$ \n\n[Neuer Kontostand]: %i$ \n\n=================================",GetPlayerBankCash(playerid)+strval(inputtext),GetPlayerBankCash(playerid));
ShowPlayerDialog(playerid,DIALOG_NEWMONEY,0,"Kontoauszug",string,"Bestätigen","Abbrechen");
GetPlayerName(tmpid[playerid],name2, sizeof(name2));
GetPlayerName(playerid, name, sizeof(name));
format(string2, sizeof(string2),"%s hat dir %i$ überwiesen!",name,tmpmoney[playerid]);
format(string3, sizeof(string3),"Du hast %s %i$ überwiesen!",name2,tmpmoney[playerid]);
SendClientMessage(playerid, COLOR_GREY, string3);
SendClientMessage(tmpid[playerid],COLOR_GREY, string2);
}
}
}
}
else
{
switch(dialogid)
{
case DIALOG_EINZAHLEN: ShowPlayerDialog(playerid, DIALOG_BANK,2,"PR Bankautomat","Abheben\r\nEinzahlen\r\nÜberweisen\r\nKontoauszug","Bestätigen","Abbrechen");
case DIALOG_ABHEBEN: ShowPlayerDialog(playerid, DIALOG_BANK,2,"PR Bankautomat","Abheben\r\nEinzahlen\r\nÜberweisen\r\nKontoauszug","Bestätigen","Abbrechen");
case DIALOG_NEWMONEY: ShowPlayerDialog(playerid, DIALOG_BANK,2,"PR Bankautomat","Abheben\r\nEinzahlen\r\nÜberweisen\r\nKontoauszug","Bestätigen","Abbrechen");
case DIALOG_UBERWEISEN: ShowPlayerDialog(playerid, DIALOG_BANK,2,"PR Bankautomat","Abheben\r\nEinzahlen\r\nÜberweisen\r\nKontoauszug","Bestätigen","Abbrechen");
case DIALOG_UBERWEISUNG: ShowPlayerDialog(playerid, DIALOG_BANK,2,"PR Bankautomat","Abheben\r\nEinzahlen\r\nÜberweisen\r\nKontoauszug","Bestätigen","Abbrechen");
}
}
return 1;
}
stock IsNumeric(const string[]) //By Mike
{
for (new i = 0, j = strlen(string); i < j; i++)
{
if (string[i] > '9' || string[i] < '0') return 0;
}
return 1;
}
stock GetPlayerId(playername[]) //By Alex "Y_Less" Cole (Edited by Sacky)
{
new playername2[MAX_PLAYER_NAME];
for (new i = 0; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
GetPlayerName(i,playername2,sizeof(playername2));
if(strcmp(playername,playername2,true)==0)
{
return i;
}
}
}
return INVALID_PLAYER_ID;
}