Sziasztok! Ez életem elsõ saját scriptje úgyhogy nelegyetek dúrvák!
Készítette: SkypeDead (én)
Elkészítési idõ: 10-15 perc
#include <a_samp>
#include <Dini>
#define PlayerFile \"Bank/%s.ini\"
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, \"\")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
enum PLAYER_MAIN {
Deposit,
};
new pInfo[MAX_PLAYERS][PLAYER_MAIN];
new GetinBank;
new GetoutBank;
new chosenpid;
public OnFilterScriptInit()
{
GetinBank = CreatePickup(1318, 1, 1480.7727,-1751.8325,15.2566);
GetoutBank = CreatePickup(1318, 1, 2304.9985,-16.1407,26.7422);
SetTimer(\"CallConnect\",1,0);
return 1;
}
forward CallConnect(playerid);
public CallConnect(playerid)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
OnPlayerConnect(i);
}
return 1;
}
public OnPlayerConnect(playerid)
{
SetPlayerMapIcon(playerid, 12, 1481.283813, -1770.431152, 18.795755, 52, 1);
new file[100],Name[MAX_PLAYER_NAME]; GetPlayerName(playerid,Name,sizeof(Name)); format(file,sizeof(file),PlayerFile,Name);
if(!dini_Exists(file)) {
dini_Create(file);
dini_IntSet(file,\"Berak\",pInfo[playerid][Deposit]);
}
else if(dini_Exists(file))
{
pInfo[playerid][Deposit] = dini_Int(file,\"Berak\");
}
return 1;
}
public OnPlayerSpawn(playerid)
{
return 1;
}
public OnPlayerPickUpPickup(playerid,pickupid)
{
if(pickupid == GetinBank)
{
SetPlayerPos(playerid,2313,-4, 27);
SendClientMessage(playerid,COLOR_YELLOW,\"Beszeretnél tenni/kivenni pénzt a bankba/ból -> {FF0000}/bank\");
SetCameraBehindPlayer(playerid);
return 0;
}
if(pickupid == GetoutBank)
{
SetPlayerPos(playerid,1480.7651,-1744.5024,13.5469);
SetPlayerFacingAngle(playerid,0.0);
SetCameraBehindPlayer(playerid);
return 0;
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new file[100],Name[MAX_PLAYER_NAME]; GetPlayerName(playerid,Name,sizeof(Name)); format(file,sizeof(file),PlayerFile,Name);
dini_IntSet(file,\"Berak\",pInfo[playerid][Deposit]);
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 1122) //deposit
{
new file[100],Name[MAX_PLAYER_NAME]; GetPlayerName(playerid,Name,sizeof(Name)); format(file,sizeof(file),PlayerFile,Name);
if(!response) return ShowPlayerDialog(playerid,1125,DIALOG_STYLE_LIST,\"Bank\",\"{CDF917}Berak\\n{33CCFF}Kivesz\\n{33FF33}Egyenleg\\n{FF0000}Átutalás\",\"Választ\",\"Mégse\");
else if(strval(inputtext) > GetPlayerMoney(playerid)) return SendClientMessage(playerid,COLOR_RED,\"Neked nincs annyi pénzed!\");
else if(!IsNumeric(inputtext))
{
new string[128];
format(string,sizeof(string),\"Mostani egyenleged : %d\\nAdja meg a kívánt összeget Betéti alatt :\",pInfo[playerid][Deposit]);
ShowPlayerDialog(playerid,1122,DIALOG_STYLE_INPUT,\"Berak\",string,\"Berak\",\"Mégse\");
SendClientMessage(playerid,COLOR_RED,\"Kérlek Számokat Használd!\");
}
else
{
GivePlayerMoney(playerid,-strval(inputtext));
pInfo[playerid][Deposit] += strval(inputtext);
new string[128];
format(string,sizeof(string),\"Beraktál : %d$\",strval(inputtext));
SendClientMessage(playerid,COLOR_YELLOW,string);
dini_IntSet(file,\"Berak\",pInfo[playerid][Deposit]);
new string2[128]; format(string2,128,\"Új egyenleged : {FF0000}%d$\",pInfo[playerid][Deposit]);
SendClientMessage(playerid,COLOR_YELLOW,string2);
ShowPlayerDialog(playerid,1125,DIALOG_STYLE_LIST,\"Bank\",\"{CDF917}Berak\\n{33CCFF}Kivesz\\n{33FF33}Egyenleg\\n{FF0000}Átutalás\",\"Választ\",\"Mégse\");
}
return 1;
}
if(dialogid == 1123) //withdraw
{
new file[100],Name[MAX_PLAYER_NAME]; GetPlayerName(playerid,Name,sizeof(Name)); format(file,sizeof(file),PlayerFile,Name);
if(!response) return ShowPlayerDialog(playerid,1125,DIALOG_STYLE_LIST,\"Bank\",\"{CDF917}Berak\\n{33CCFF}Kivesz\\n{33FF33}Egyenleg\\n{FF0000}Átutalás\",\"Választ\",\"Mégse\");
else if(strval(inputtext) > pInfo[playerid][Deposit]) return SendClientMessage(playerid,COLOR_RED,\"Nincs elég pénzed!\");
else if(!IsNumeric(inputtext))
{
new string[128];
format(string,sizeof(string),\"Mostani egyenleged :{CDF917}%d\\n{FF0000}Adja meg a kívánt összeg amit ki akar venni:\",pInfo[playerid][Deposit]);
ShowPlayerDialog(playerid,1123,DIALOG_STYLE_INPUT,\"Felvesz\",string,\"Felvesz\",\"Mégse\");
SendClientMessage(playerid,COLOR_RED,\"Kérlek Számokat használj!\");
}
else
{
GivePlayerMoney(playerid,strval(inputtext));
pInfo[playerid][Deposit] -= strval(inputtext);
new string[128];
format(string,sizeof(string),\"Te kivettél : %d$\",strval(inputtext));
SendClientMessage(playerid,COLOR_YELLOW,string);
dini_IntSet(file,\"Berak\",pInfo[playerid][Deposit]);
new string2[128]; format(string2,128,\"Új egyenleged : %d$\",pInfo[playerid][Deposit]);
SendClientMessage(playerid,COLOR_YELLOW,string2);
ShowPlayerDialog(playerid,1125,DIALOG_STYLE_LIST,\"Bank\",\"{CDF917}Berak\\n{33CCFF}Kivesz\\n{33FF33}Egyenleg\\n{FF0000}Átutalás\",\"Választ\",\"Mégse\");
}
return 1;
}
if(dialogid == 1124)
{
if(!response) return ShowPlayerDialog(playerid,1125,DIALOG_STYLE_LIST,\"Bank\",\"{CDF917}Berak\\n{33CCFF}Kivesz\\n{33FF33}Egyenleg\\n{FF0000}Átutalás\",\"Választ\",\"Mégse\");
else
{
ShowPlayerDialog(playerid,1125,DIALOG_STYLE_LIST,\"Bank\",\"{CDF917}Berak\\n{33CCFF}Kivesz\\n{33FF33}Egyenleg\\n{FF0000}Átutalás\",\"Választ\",\"Mégse\");
}
return 1;
}
if(dialogid == 1130) //transfer (choose playerid)
{
if(!response) return ShowPlayerDialog(playerid,1125,DIALOG_STYLE_LIST,\"Bank\",\"{CDF917}Berak\\n{33CCFF}Kivesz\\n{33FF33}Egyenleg\\n{FF0000}Átutalás\",\"Választ\",\"Mégse\");
else if(strval(inputtext) == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,\"Játékos nem elérhetõ\");
else if(!IsNumeric(inputtext))
{
new string[128];
format(string,sizeof(string),\"Mostani egyenleged :%d$\\n{FF0000}Ird be a játékos ID jét akinek akarod küldeni a pénzt :\",pInfo[playerid][Deposit]);
ShowPlayerDialog(playerid,1130,DIALOG_STYLE_INPUT,\"Átutalás\",string,\"Tovább\",\"Mégse\");
SendClientMessage(playerid,COLOR_RED,\"Kérlek ID t irj és ne a nevét!!!!\");
}
else
{
chosenpid = strval(inputtext);
new string[128];
format(string,sizeof(string),\"Egyenleged : {33FF33}%d\\n {FF0000}Kiválasztott Player ID : %d\\nMost ird be az összeget amit át szeretnél utalni a playernek\",pInfo[playerid][Deposit],chosenpid);
ShowPlayerDialog(playerid,1131,DIALOG_STYLE_INPUT,\"Átutalás\",string,\"Átutalás\",\"Mégse\");
}
return 1;
}
if(dialogid == 1131) //transfer (choose amount)
{
new file[100],Name[MAX_PLAYER_NAME]; GetPlayerName(playerid,Name,sizeof(Name)); format(file,sizeof(file),PlayerFile,Name);
if(!response) return ShowPlayerDialog(playerid,1125,DIALOG_STYLE_LIST,\"Bank\",\"{CDF917}Berak\\n{33CCFF}Kivesz\\n{33FF33}Egyenleg\\n{FF0000}Átutalás\",\"Választ\",\"Mégse\");
else if(strval(inputtext) > pInfo[playerid][Deposit]) return SendClientMessage(playerid,COLOR_RED,\"Nincs elég pénzed\");
else if(!IsNumeric(inputtext))
{
new string[128];
format(string,sizeof(string),\"Kiválasztott játékos id : {33FF33}%d\\nMost ird be az összeget amit át akarsz küldeni\",chosenpid);
ShowPlayerDialog(playerid,1131,DIALOG_STYLE_INPUT,\"Átutalás\",string,\"Átutalás\",\"Mégse\");
SendClientMessage(playerid,COLOR_RED,\"Kérlek Számokat használj!\");
}
else
{
pInfo[playerid][Deposit] -= strval(inputtext);
pInfo[chosenpid][Deposit] += strval(inputtext);
new string[128];
format(string,sizeof(string),\"Te átutaltá {33FF33}%d$ To ID %d{FF0000} Bank Felhasználojára\",strval(inputtext),chosenpid);
SendClientMessage(playerid,COLOR_YELLOW,string);
dini_IntSet(file,\"Berak\",pInfo[playerid][Deposit]);
new string2[128]; format(string2,128,\"Te új egyenleged : {33FF33}%d$\",pInfo[playerid][Deposit]);
SendClientMessage(playerid,COLOR_YELLOW,string2);
new string3[128]; format(string3,128,\"ID : {33FF33}%d átutalt %d$ {FF0000}a te bankszámládra\",playerid,strval(inputtext));
SendClientMessage(chosenpid,COLOR_YELLOW,string3);
new string4[128]; format(string4,128,\"Te új egyenleged : {33FF33}%d$\",pInfo[chosenpid][Deposit]);
SendClientMessage(chosenpid,COLOR_YELLOW,string4);
ShowPlayerDialog(playerid,1125,DIALOG_STYLE_LIST,\"Bank\",\"{CDF917}Berak\\n{33CCFF}Kivesz\\n{33FF33}Egyenleg\\n{FF0000}Átutalás\",\"Választ\",\"Mégse\");
}
return 1;
}
if(dialogid == 1125 && response) // /bank
{
switch(listitem)
{
case 0:
{
new string[128];
format(string,sizeof(string),\"Mostani egyenleged : {CDF917}%d$\\n{FF0000}Ird be az összeget amit be akarsz rakni :\",pInfo[playerid][Deposit]);
ShowPlayerDialog(playerid,1122,DIALOG_STYLE_INPUT,\"Berak\",string,\"Berak\",\"Mégse\");
}
case 1:
{
new string[128];
format(string,sizeof(string),\"Mostani egyenleg {CDF917}:%d\\n{FF0000}Ird be az összeget amennyit kiszeretnél venni :\",pInfo[playerid][Deposit]);
ShowPlayerDialog(playerid,1123,DIALOG_STYLE_INPUT,\"Felvesz\",string,\"Felvesz\",\"Mégse\");
}
case 2:
{
new string[128];
format(string,sizeof(string),\"Egyenleged: {CDF917}%d$\",pInfo[playerid][Deposit]);
ShowPlayerDialog(playerid,1124,DIALOG_STYLE_MSGBOX,\"Egyenleg\",string,\"Ok\",\"Mégse\");
}
case 3:
{
new string[128];
format(string,sizeof(string),\"Mostani egyenleged {CDF917}:%d$\\n{FF0000}Ird be a játékos idjét hogy átutalj :\",pInfo[playerid][Deposit]);
ShowPlayerDialog(playerid,1130,DIALOG_STYLE_INPUT,\"Átutalás\",string,\"Tovább\",\"Mégse\");
}
}
}
return 0;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(bank,4,cmdtext);
return 0;
}
dcmd_bank(playerid,params[])
{
#pragma unused params
if(!IsPlayerInRangeOfPoint(playerid,15.0,2313,-4, 27)) return SendClientMessage(playerid,COLOR_RED,\"{FF0000}HIBA:Bankban kell lenned! {33FF33}(/bankk)\");
else
{
ShowPlayerDialog(playerid,1125,DIALOG_STYLE_LIST,\"Bank\",\"{CDF917}Berak\\n{33CCFF}Kivesz\\n{33FF33}Egyenleg\\n{FF0000}Átutalás\",\"Választ\",\"Mégse\");
}
return 1;
}
//------------------[sSCANF]-------------------------------------
stock sscanf(string[], format[], {Float,_}:...)
{
#if defined isnull
if (isnull(string))
#else
if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
#endif
{
return format[0];
}
#pragma tabsize 4
new
formatPos = 0,
stringPos = 0,
paramPos = 2,
paramCount = numargs(),
delim = \' \';
while (string[stringPos] && string[stringPos] <= \' \')
{
stringPos++;
}
while (paramPos < paramCount && string[stringPos])
{
switch (format[formatPos++])
{
case \'\\0\':
{
return 0;
}
case \'i\', \'d\':
{
new
neg = 1,
num = 0,
ch = string[stringPos];
if (ch == \'-\')
{
neg = -1;
ch = string[++stringPos];
}
do
{
stringPos++;
if (\'0\' <= ch <= \'9\')
{
num = (num * 10) + (ch - \'0\');
}
else
{
return -1;
}
}
while ((ch = string[stringPos]) > \' \' && ch != delim);
setarg(paramPos, 0, num * neg);
}
case \'h\', \'x\':
{
new
num = 0,
ch = string[stringPos];
do
{
stringPos++;
switch (ch)
{
case \'x\', \'X\':
{
num = 0;
continue;
}
case \'0\' .. \'9\':
{
num = (num << 4) | (ch - \'0\');
}
case \'a\' .. \'f\':
{
num = (num << 4) | (ch - (\'a\' - 10));
}
case \'A\' .. \'F\':
{
num = (num << 4) | (ch - (\'A\' - 10));
}
default:
{
return -1;
}
}
}
while ((ch = string[stringPos]) > \' \' && ch != delim);
setarg(paramPos, 0, num);
}
case \'c\':
{
setarg(paramPos, 0, string[stringPos++]);
}
case \'f\':
{
new changestr[16], changepos = 0, strpos = stringPos;
while(changepos < 16 && string[strpos] && string[strpos] != delim)
{
changestr[changepos++] = string[strpos++];
}
changestr[changepos] = \'\\0\';
setarg(paramPos,0,_:floatstr(changestr));
}
case \'p\':
{
delim = format[formatPos++];
continue;
}
case \'\\\'\':
{
new
end = formatPos - 1,
ch;
while ((ch = format[++end]) && ch != \'\\\'\') {}
if (!ch)
{
return -1;
}
format[end] = \'\\0\';
if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
{
if (format[end + 1])
{
return -1;
}
return 0;
}
format[end] = \'\\\'\';
stringPos = ch + (end - formatPos);
formatPos = end + 1;
}
case \'u\':
{
new
end = stringPos - 1,
id = 0,
bool:num = true,
ch;
while ((ch = string[++end]) && ch != delim)
{
if (num)
{
if (\'0\' <= ch <= \'9\')
{
id = (id * 10) + (ch - \'0\');
}
else
{
num = false;
}
}
}
if (num && IsPlayerConnected(id))
{
setarg(paramPos, 0, id);
}
else
{
#if !defined foreach
#define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
#define __SSCANF_FOREACH__
#endif
string[end] = \'\\0\';
num = false;
new
name[MAX_PLAYER_NAME];
id = end - stringPos;
foreach (Player, playerid)
{
GetPlayerName(playerid, name, sizeof (name));
if (!strcmp(name, string[stringPos], true, id))
{
setarg(paramPos, 0, playerid);
num = true;
break;
}
}
if (!num)
{
setarg(paramPos, 0, INVALID_PLAYER_ID);
}
string[end] = ch;
#if defined __SSCANF_FOREACH__
#undef foreach
#undef __SSCANF_FOREACH__
#endif
}
stringPos = end;
}
case \'s\', \'z\':
{
new
i = 0,
ch;
if (format[formatPos])
{
while ((ch = string[stringPos++]) && ch != delim)
{
setarg(paramPos, i++, ch);
}
if (!i)
{
return -1;
}
}
else
{
while ((ch = string[stringPos++]))
{
setarg(paramPos, i++, ch);
}
}
stringPos--;
setarg(paramPos, i, \'\\0\');
}
default:
{
continue;
}
}
while (string[stringPos] && string[stringPos] != delim && string[stringPos] > \' \')
{
stringPos++;
}
while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= \' \'))
{
stringPos++;
}
paramPos++;
}
do
{
if ((delim = format[formatPos++]) > \' \')
{
if (delim == \'\\\'\')
{
while ((delim = format[formatPos++]) && delim != \'\\\'\') {}
}
else if (delim != \'z\')
{
return delim;
}
}
}
while (delim > \' \');
return 0;
}
stock IsNumeric(string[])
{
for (new i = 0, j = strlen(string); i < j; i++)
{
if (string > \'9\' || string < \'0\') return 0;
}
return 1;
}