#include <a_samp>
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_YELLOW 0xFFFF00AA
#include <dini>
#include <dudb>
forward SavedUpdate();
new bank[MAX_PLAYERS];
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256];
new idx;
new bank[MAX_PLAYERS];
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/speichern", true) == 0 )
{
new tmp[256];
new moneys;
new string[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "Benutzung: /speichern [Geldbetrag]");
return 1;
}
moneys = strval(tmp);
if(GetPlayerMoney(playerid) < moneys)
{
moneys = GetPlayerMoney(playerid);
}
GivePlayerMoney(playerid, 0-moneys);
bank[playerid]+=moneys;
format(string, sizeof(string), "Du hast %d$ gespeichert, dein Kontostand lautet: %d$", moneys, bank[playerid]);
SendClientMessage(playerid, COLOR_YELLOW, string);
return 1;
}
if(strcmp(cmd, "/abheben", true) == 0)
{
new string[256];
new moneys;
new tmp[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "Benutzung: /abheben [Geldbetrag]");
return 1;
}
moneys = strval(tmp);
if(moneys > bank[playerid])
moneys = bank[playerid];
GivePlayerMoney(playerid, moneys);
bank[playerid] -= moneys;
format(string, sizeof(string), "Du hast %d$ abgehoben, dein Kontostand lautet: %d$", moneys, bank[playerid]);
SendClientMessage(playerid, COLOR_YELLOW, string);
return 1;
}
if(strcmp(cmd, "/konto", true) == 0)
{
new string[256];
format(string, sizeof(string), "Dein Kontostand lautet: %d$", bank[playerid]);
SendClientMessage(playerid, COLOR_YELLOW, string);
return 1;
}
return 0;
}
stock PlayerName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
return name;
}
public OnPlayerConnect(playerid)
{
if (!udb_Exists(PlayerName(playerid)))
{
new fname[MAX_STRING];
format(fname,sizeof(fname),"%s.sav",udb_encode(PlayerName(playerid)));
dini_Create(fname);
}
if (udb_Exists(PlayerName(playerid)))
{
bank[playerid]=dUserINT(PlayerName(playerid)).("bank");
}
return 1;
}
public SavedUpdate()
{
for (new i; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
dUserSetINT(PlayerName(i)).("bank",bank);
}
}
}
das broblem ist der speichert das geld nicht mach kann bei /kont gucken und dann steht da imma 0
ich hab nur eine warnung:
C:\DOKUME~1\Marcel\Desktop\Sever\FILTER~1\bank.pwn(25) : warning 219: local variable "bank" shadows a variable at a preceding level
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
1 Warning.