29.05.2016, 20:53
Please, with this script do on ZCMD please YES: #include <a_samp> and #include <zcmd>. NO NEVER #include <dini>
Код:
#include <a_samp>
#include <dini>
#define PlayerFile "Bank/%s.ini"
#define COLOR 0xFFFF9900
#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 Bank1;
new Bank2;
new chosenpid;
public OnFilterScriptInit()
{
Bank1 = CreatePickup(1274, 1, 1481.283813, -1770.431152, 18.795755, 0);
Bank2 = CreatePickup(1274, 1, 2304.675537, -16.035686, 26.742187, 0);
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,"Deposit",pInfo[playerid][Deposit]);
}
else if(dini_Exists(file))
{
pInfo[playerid][Deposit] = dini_Int(file,"Deposit");
}
return 1;
}
public OnPlayerSpawn(playerid)
{
return 1;
}
public OnPlayerPickUpPickup(playerid,pickupid)
{
if(pickupid == Bank1)
{
SetPlayerPos(playerid,2313,-4, 27);
SendClientMessage(playerid,COLOR,"Wpisz /bank");
SetCameraBehindPlayer(playerid);
return 0;
}
if(pickupid == Bank2)
{
SetPlayerPos(playerid,1481.130371,-1763.401000, 18.795755);
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,"Deposit",pInfo[playerid][Deposit]);
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 1122)
{
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","Wplac\nWyplac\nSaldo\nTransfer","Wybierz","Anuluj");
else if(strval(inputtext) > GetPlayerMoney(playerid)) return SendClientMessage(playerid,COLOR,"Nie masz takiej kwoty w banku!");
else if(!IsNumeric(inputtext))
{
new string[128];
format(string,sizeof(string),"Aktualny stan konta wynosi: %d$\nWprowadz ponizej kwote ktora chcesz wplacic :",pInfo[playerid][Deposit]);
ShowPlayerDialog(playerid,1122,DIALOG_STYLE_INPUT,"Wplac",string,"Wplac","Wstecz");
SendClientMessage(playerid,COLOR,"Prosimy uzywac liczb");
}
else
{
GivePlayerMoney(playerid,-strval(inputtext));
pInfo[playerid][Deposit] += strval(inputtext);
new string[128];
format(string,sizeof(string),"Masz wplacone: %d$",strval(inputtext));
SendClientMessage(playerid,COLOR,string);
dini_IntSet(file,"Wplac",pInfo[playerid][Deposit]);
new string2[128]; format(string2,128,"Twoje nowe saldo wynosi: %d$",pInfo[playerid][Deposit]);
SendClientMessage(playerid,COLOR,string2);
ShowPlayerDialog(playerid,1125,DIALOG_STYLE_LIST,"Bank","Wplac\nWyplac\nSaldo\nTransfer","Wybierz","Anuluj");
}
return 1;
}
if(dialogid == 1123)
{
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","Wplac\nWyplac\nSaldo\nTransfer","Wybierz","Anuluj");
else if(strval(inputtext) > pInfo[playerid][Deposit]) return SendClientMessage(playerid,COLOR,"Nie masz takiej kwoty w banku!");
else if(!IsNumeric(inputtext))
{
new string[128];
format(string,sizeof(string),"Aktualny stan konta wynosi: %d$\nWprowadz ponizej kwote ktora chcesz wyplacic :",pInfo[playerid][Deposit]);
ShowPlayerDialog(playerid,1123,DIALOG_STYLE_INPUT,"Wyplac",string,"Wyplac","Wstecz");
SendClientMessage(playerid,COLOR,"Prosze uzywac liczb");
}
else
{
GivePlayerMoney(playerid,strval(inputtext));
pInfo[playerid][Deposit] -= strval(inputtext);
new string[128];
format(string,sizeof(string),"Wyplaciles: %d$",strval(inputtext));
SendClientMessage(playerid,COLOR,string);
dini_IntSet(file,"Wplac",pInfo[playerid][Deposit]);
new string2[128]; format(string2,128,"Twoje nowe saldo wynosi: %d$",pInfo[playerid][Deposit]);
SendClientMessage(playerid,COLOR,string2);
ShowPlayerDialog(playerid,1125,DIALOG_STYLE_LIST,"Bank","Wplac\nWyplac\nSaldo\nTransfer","Wybierz","Anuluj");
}
return 1;
}
if(dialogid == 1124)
{
if(!response) return ShowPlayerDialog(playerid,1125,DIALOG_STYLE_LIST,"Bank","Wplac\nWyplac\nSaldo\nTransfer","Wybierz","Anuluj");
else
{
ShowPlayerDialog(playerid,1125,DIALOG_STYLE_LIST,"Bank","Wplac\nWyplac\nSaldo\nTransfer","Wybierz","Anuluj");
}
return 1;
}
if(dialogid == 1130)
{
if(!response) return ShowPlayerDialog(playerid,1125,DIALOG_STYLE_LIST,"Bank","Wplac\nWyplac\nSaldo\nTransfer","Wybierz","Anuluj");
else if(strval(inputtext) == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR,"Gracz nie jest dostepny");
else if(!IsNumeric(inputtext))
{
new string[128];
format(string,sizeof(string),"Aktualny stan konta wynosi: %d$\nWprowadz ponizej kwote ktora chcesz wplacic :",pInfo[playerid][Deposit]);
ShowPlayerDialog(playerid,1130,DIALOG_STYLE_INPUT,"Transfer",string,"Dalej","Wstecz");
SendClientMessage(playerid,COLOR,"Prosimy uzyc ID gracza a nie nazwe");
}
else
{
chosenpid = strval(inputtext);
new string[128];
format(string,sizeof(string),"Saldo: %d\nWybrano ID gracza: %d\nTeraz wprowadz kwote ktora chcesz przelac",pInfo[playerid][Deposit],chosenpid);
ShowPlayerDialog(playerid,1131,DIALOG_STYLE_INPUT,"Transfer",string,"Transfer","Wstecz");
}
return 1;
}
if(dialogid == 1131)
{
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","Wplac\nWyplac\nSaldo\nTransfer","Wybierz","Anuluj");
else if(strval(inputtext) > pInfo[playerid][Deposit]) return SendClientMessage(playerid,COLOR,"Nie masz takiej kwoty w banku, aby dokonac przelewu");
else if(!IsNumeric(inputtext))
{
new string[128];
format(string,sizeof(string),"Wybrano ID gracza: %d\nWpisz kwote ktora chcesz przelac",chosenpid);
ShowPlayerDialog(playerid,1131,DIALOG_STYLE_INPUT,"Transfer",string,"Transfer","Wstecz");
SendClientMessage(playerid,COLOR,"Prosimy używac liczb");
}
else
{
pInfo[playerid][Deposit] -= strval(inputtext);
pInfo[chosenpid][Deposit] += strval(inputtext);
new string[128];
format(string,sizeof(string),"Przeslales %d$ na ID %d",strval(inputtext),chosenpid);
SendClientMessage(playerid,COLOR,string);
dini_IntSet(file,"Wplac",pInfo[playerid][Deposit]);
new string2[128]; format(string2,128,"Twoje nowe saldo: %d$",pInfo[playerid][Deposit]);
SendClientMessage(playerid,COLOR,string2);
new string3[128]; format(string3,128,"ID : %d Przeniesiono %d$ na Twoje konto bankowe",playerid,strval(inputtext));
SendClientMessage(chosenpid,COLOR,string3);
new string4[128]; format(string4,128,"Twoje nowe saldo: %d$",pInfo[chosenpid][Deposit]);
SendClientMessage(chosenpid,COLOR,string4);
ShowPlayerDialog(playerid,1125,DIALOG_STYLE_LIST,"Bank","Wplac\nWyplac\nSaldo\nTransfer","Wybierz","Anuluj");
}
return 1;
}
if(dialogid == 1125 && response)
{
switch(listitem)
{
case 0:
{
new string[128];
format(string,sizeof(string),"Aktualny stan konta wynosi: %d$\nWprowadz ponizej kwote ktora chcesz wplacic :",pInfo[playerid][Deposit]);
ShowPlayerDialog(playerid,1122,DIALOG_STYLE_INPUT,"Wplac",string,"Wplac","Wstecz");
}
case 1:
{
new string[128];
format(string,sizeof(string),"Aktualny stan konta wynosi: %d$\nWprowadz ponizej kwote ktora chcesz wyplacic :",pInfo[playerid][Deposit]);
ShowPlayerDialog(playerid,1123,DIALOG_STYLE_INPUT,"Wyplac",string,"Wyplac","Wstecz");
}
case 2:
{
new string[128];
format(string,sizeof(string),"Saldo na koncie wynosi: %d$",pInfo[playerid][Deposit]);
ShowPlayerDialog(playerid,1124,DIALOG_STYLE_MSGBOX,"Saldo",string,"Ok","Wstecz");
}
case 3:
{
new string[128];
format(string,sizeof(string),"Aktualny stan konta wynosi: %d$\nWprowadz ponizej ID gracza ktoremu chcesz przelac pieniadze :",pInfo[playerid][Deposit]);
ShowPlayerDialog(playerid,1130,DIALOG_STYLE_INPUT,"Transfer",string,"Dalej","Wstecz");
}
}
}
return 0;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(bank,4,cmdtext);
dcmd(banktele,8,cmdtext);
return 0;
}
dcmd_bank(playerid,params[])
{
#pragma unused params
if(!IsPlayerInRangeOfPoint(playerid,15.0,2313,-4, 27)) return SendClientMessage(playerid,COLOR,"Musisz być w banku");
else
{
ShowPlayerDialog(playerid,1125,DIALOG_STYLE_LIST,"Bank","Wplac\nWyplac\nStan konta\nTransfer","Wybierz","Anuluj");
}
return 1;
}
dcmd_banktele(playerid,params[])
{
#pragma unused params
SetPlayerPos(playerid,1481.049804,-1745.565673,13.667258);
SendClientMessage(playerid,COLOR,"Witamy w banku");
SetPlayerFacingAngle(playerid,180.0);
SetCameraBehindPlayer(playerid);
return 1;
}
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[i] > '9' || string[i] < '0') return 0;
}
return 1;
}


