Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // =============================================================================
- // =============================================================================
- // ------------------------- Scripter : Pawno ----------------------------------
- // =============================================================================
- // =============================================================================
- // ------------------------------- Biblioteci ----------------------------------
- #include <a_samp>
- #include <dutils>
- #include <dini>
- // =============================================================================
- // ------------------------------- Definitii -----------------------------------
- #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
- #define Fisier_Banca "Banca/%s.ini";
- // =============================================================================
- // -------------------------------- Creatii ------------------------------------
- new Banca;
- new Float:Spawn_Aleatoriu [][] =
- {
- {1742.5667, -1860.1587, 13.5791, 359.4921}, // Gara.
- {1642.2238, -2332.9924, 13.5469, 359.0938}, // Aeroport.
- {820.9525, -1341.7852, 13.5209, 91.0803} // Metro.
- };
- new Float:Bancomat [][] =
- {
- {1553.2744, -1668.3151, 13.5569, 266.7286},
- {1929.2637, -1786.0145, 13.5469, 88.5060},
- {1750.7115, -1862.8801, 13.5758, 181.6880},
- {1172.0929, -1319.5659 ,15.3947, 358.0941}
- };
- // =============================================================================
- // -------------------------------- Pragma -------------------------------------
- #pragma unused ret_memcpy
- #pragma unused strtok
- #pragma tabsize 0
- // =============================================================================
- // ------------------------------ Enumeratii -----------------------------------
- enum pInfo
- {
- pAdmin,
- pLevel,
- pMoney,
- pPassword,
- pBalance,
- pBank,
- }
- new PlayerInfo[MAX_PLAYERS][pInfo];
- new BankInfo[MAX_PLAYERS][pInfo];
- // =============================================================================
- // ------------------------ Deschiderea Gamemode-ului --------------------------
- public OnGameModeInit()
- {
- print("===============================");
- print("===============================");
- print("--- Gamemode-ul se incarca. ---");
- print("-- Gamemode-ul s-a incarcat. --");
- print("===============================");
- print("===============================");
- CreateObject(2942, 1553.8000488281, -1667.6999511719, 13.199999809265, 0, 0, 270); // Bancomat.
- CreateObject(2942, 1928.5999755859, -1785.8000488281, 13.199999809265, 0, 0, 92); // Bancomat.
- CreateObject(2942, 1750.6999511719, -1863.5999755859, 13.199999809265, 0, 0, 180); // Bancomat.
- CreateObject(2942, 1172.3000488281, -1318.9000244141, 15, 0, 0, 0); // Bancomat.
- return 1;
- }
- // =============================================================================
- // ------------------------ Conectarea jucatorului -----------------------------
- public OnPlayerConnect(playerid)
- {
- new Nume[MAX_PLAYER_NAME];
- new Fisier[128];
- GetPlayerName(playerid, Nume, MAX_PLAYER_NAME);
- format(Fisier, sizeof(Fisier), ".../Conturi/%s.ini", Nume);
- if (!fexist(Fisier))
- {
- SendClientMessage(playerid, 0xFFFFFF, "{CC66CC}*** {3366CC}[Informatie] {FFCC99}Acest cont nu este inregistrat in baza noastra de date. {CC66CC}***");
- ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Fereastra de inregistrare", "Bun venit pe serverul Define Roleplay. /nAcest cont nu este inregistrat in baza noastra de date. /nIntrodu parola dorita in casuta de mai jos pentru a inregistra contul in baza noastra de date.", "Ok", "Renunta");
- }
- else
- {
- new Mesaj[128];
- GetPlayerName(playerid, Nume, MAX_PLAYER_NAME);
- format(Mesaj, sizeof(Mesaj), "{CC66CC}*** {3366CC}[Informatie] {FFCC99}Bine ai revenit pe Define Roleplay, %s. {CC66CC}***", Nume);
- SendClientMessage(playerid, 0xFFFFFF, Mesaj);
- ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Fereastra de logare", "Bine ai revenit pe serverul Define Roleplay. /nAcest cont este inregistrat in baza noastra de date. /nIntrodu parola contului in casuta de mai jos pentru a te conecta.", "Ok", "Renunta");
- }
- Banca = CreatePickup(1242, 2, 595.5361, -1250.6130, 18.2915, -1);
- new Nume2[24];
- new Fisier2[128];
- GetPlayerName(playerid, Nume2, 24);
- if(!fexist(Fisier2))
- {
- dini_Create(Fisier2);
- dini_IntSet(Fisier2, "pBalance", 0);
- dini_IntSet(Fisier2, "pBank", 0);
- }
- else
- {
- BankInfo[playerid][pBalance] = dini_IntSet(Fisier2, "pBalance");
- BankInfo[playerid][pBank] = dini_IntSet(Fisier2, "pBank");
- }
- return 1;
- }
- // =============================================================================
- // ----------------------- Spawn-ul jucatorilor --------------------------------
- public OnPlayerSpawn(playerid)
- {
- new Aleatoriu = random(sizeof(Spawn_Aleatoriu));
- SetPlayerPos(playerid, Spawn_Aleatoriu [Aleatoriu][0], Spawn_Aleatoriu [Aleatoriu][1], Spawn_Aleatoriu [Aleatoriu][2]);
- SetPlayerFacingAngle(playerid, Spawn_Aleatoriu [Aleatoriu][3]);
- return 1;
- }
- // =============================================================================
- // -------------------- Deconectarea jucatorului -------------------------------
- public OnPlayerDisconnect(playerid, reason)
- {
- new Fisier[128];
- new Nume[MAX_PLAYER_NAME];
- GetPlayerName(playerid, Nume, MAX_PLAYER_NAME);
- format(Fisier, sizeof(Fisier), ".../Conturi/%s.ini", Nume);
- if (dini_Exists(Fisier))
- {
- dini_IntSet(Fisier, "pAdmin", PlayerInfo[playerid][pAdmin]);
- dini_IntSet(Fisier, "pLevel", PlayerInfo[playerid][pLevel]);
- dini_IntSet(Fisier, "pMoney", PlayerInfo[playerid][pMoney]);
- dini_IntSet(Fisier, "pPassword", PlayerInfo[playerid][pPassword]);
- }
- BankInfo[playerid][pBank] = 0;
- new Nume2[24];
- new Fisier2[128];
- GetPlayerName(playerid, Nume2, 24);
- dini_IntSet(Fisier2, "pBalance", BankInfo[playerid][pBalance]);
- dini_IntSet(Fisier2, "pBank", BankInfo[playerid][pBank]);
- return 1;
- }
- // =============================================================================
- // ----------------------- Comanda jucatorului ---------------------------------
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- dcmd(bankhelp, 8, cmdtext);
- dcmd(withdraw, 8, cmdtext);
- dcmd(deposit, 7, cmdtext);
- dmcd(transfer, 5, cmdtext);
- dcmd(balance, 7, cmdtext);
- return 1;
- }
- // =============================================================================
- // ---------------------------- Comenzile --------------------------------------
- dcmd_bankhelp (playerid, params[])
- {
- #pragma unused params
- SendClientMessage(playerid, 0xFFFFFF, "{CC66CC}*** {3366CC}[Informatie] {FFCC99}Comenzile disponibile sunt : /withdraw, /deposit, /transfer, /balance. {CC66CC}***");
- return 1;
- }
- dcmd_withdraw (playerid, params[])
- {
- new Suma;
- if (sscanf(params, "d", Suma)
- {
- return SendClientMessage(playerid, 0xFFFFFF, "{CC66CC}*** {3366CC}[Informatie] {FFCC99}Forma corecta este '/withdraw [Suma]'. {CC66CC}***");
- }
- else if (Suma > BankInfo[playerid][pBalance])
- {
- return SendClientMessage(playerid, 0xFFFFFF, "{CC66CC}*** {CC0000}[Eroare] {FFCC99}Nu ai asa de multi bani in cont. {CC66CC}***");
- }
- else if (BankInfo[playerid][pBank] == 0)
- {
- if (IsPlayerInRangeOfPoint(playerid, 5.0, Bancomat [0][0], Bancomat [0][1], Bancomat [0][2])
- {
- BankInfo[playerid][pBalance] -= Suma;
- GivePlayerMoney(playerid, Suma);
- new Mesaj[256];
- format(Mesaj, sizeof(Mesaj), "{CC66CC}*** {3366CC}[Informatie] {FFCC99}Ai extras din cont %d $. Mai ai in cont %d $. {CC66CC}***", Suma, BankInfo[playerid][pBalance]);
- SendClientMessage(playerid, 0xFFFFFF, Mesaj);
- }
- if (IsPlayerInRangeOfPoint(playerid, 5.0, Bancomat [1][0], Bancomat [1][1], Bancomat [1][2])
- {
- BankInfo[playerid][pBalance] -= Suma;
- GivePlayerMoney(playerid, Suma);
- new Mesaj[256];
- format(Mesaj, sizeof(Mesaj), "{CC66CC}*** {3366CC}[Informatie] {FFCC99}Ai extras din cont %d $. Mai ai in cont %d $. {CC66CC}***", Suma, BankInfo[playerid][pBalance]);
- SendClientMessage(playerid, 0xFFFFFF, Mesaj);
- }
- if (IsPlayerInRangeOfPoint(playerid, 5.0, Bancomat [2][0], Bancomat [2][1], Bancomat [2][2])
- {
- BankInfo[playerid][pBalance] -= Suma;
- GivePlayerMoney(playerid, Suma);
- new Mesaj[256];
- format(Mesaj, sizeof(Mesaj), "{CC66CC}*** {3366CC}[Informatie] {FFCC99}Ai extras din cont %d $. Mai ai in cont %d $. {CC66CC}***", Suma, BankInfo[playerid][pBalance]);
- SendClientMessage(playerid, 0xFFFFFF, Mesaj);
- }
- if (IsPlayerInRangeOfPoint(playerid, 5.0, Bancomat [3][0], Bancomat [3][1], Bancomat [3][2])
- {
- BankInfo[playerid][pBalance] -= Suma;
- GivePlayerMoney(playerid, Suma);
- new Mesaj[256];
- format(Mesaj, sizeof(Mesaj), "{CC66CC}*** {3366CC}[Informatie] {FFCC99}Ai extras din cont %d $. Mai ai in cont %d $. {CC66CC}***", Suma, BankInfo[playerid][pBalance]);
- SendClientMessage(playerid, 0xFFFFFF, Mesaj);
- }
- else
- {
- SendClientMessage(playerid, 0xFFFFFF, "{CC66CC}*** {3366CC}[Informatie] {FFCC99}Trebuie sa fii la banca sau la unul dintre bancomate sa poti folosi aceasta comanda. {CC66CC}***");
- }
- }
- else if (BankInfo[playerid][pBalance] < 0)
- {
- BankInfo[playerid][pBalance] -= Suma;
- GivePlayerMoney(playerid, Suma);
- new Mesaj[256];
- format(Mesaj, sizeof(Mesaj), "{CC66CC]*** {3366CC}[Informatie] {FFCC99}Ai extras din cont %d $. Mai ai in cont %d $. {CC66CC}***", Suma, BankInfo[playerid][pBalance]);
- SendClientMessage(playerid, 0xFFFFFF, Mesaj);
- }
- return 1;
- }
- dcmd_deposit (playerid, params[])
- {
- new Suma;
- new Bani;
- Bani = GetPlayerMoney(playerid);
- if (sscanf(params, "d", Suma)
- {
- return SendClientMessage(playerid, 0xFFFFFF, "{CC66CC}*** {3366CC}[Informatie] {FFCC99}Forma corecta este '/deposit [Suma]'. {CC66CC]***");
- }
- else if (GetPlayerMoney(playerid) < Suma)
- {
- SendClientMessage(playerid, 0xFFFFFF, "{CC66CC}*** {3366CC}[Informatie] {FFCC99}Nu ai suficienti bani in cont. {CC66CC}***");
- }
- else if (BankInfo[playerid][pBank] == 0)
- {
- IsPlayerInRangeOfPoint(playerid, 5.0, Bancomat [0][0], Bancomat [0][1], Bancomat [0][2])
- {
- BankInfo[playerid][pBalance] += Suma;
- GivePlayerMoney(playerid, -Suma);
- new Mesaj[256];
- format(Mesaj, sizeof(Mesaj), "{CC66CC}*** {3366CC}[Informatie] {FFCC99}Ai extras din cont %d $. Mai ai in cont %d $. {CC66CC}***", Suma, BankInfo[playerid][pBalance]);
- SendClientMessage(playerid, 0xFFFFFF, Mesaj);
- }
- IsPlayerInRangeOfPoint(playerid, 5.0, Bancomat [1][0], Bancomat [1][1], Bancomat [1][2])
- {
- BankInfo[playerid][pBalance] += Suma;
- GivePlayerMoney(playerid, -Suma);
- new Mesaj[256];
- format(Mesaj, sizeof(Mesaj), "{CC66CC}*** {3366CC}[Informatie] {FFCC99}Ai extras din cont %d $. Mai ai in cont %d $. {CC66CC}***", Suma, BankInfo[playerid][pBalance]);
- SendClientMessage(playerid, 0xFFFFFF, Mesaj);
- }
- IsPlayerInRangeOfPoint(playerid, 5.0, Bancomat [2][0], Bancomat [2][1], Bancomat [2][2])
- {
- BankInfo[playerid][pBalance] += Suma;
- GivePlayerMoney(playerid, -Suma);
- new Mesaj[256];
- format(Mesaj, sizeof(Mesaj), "{CC66CC}*** {3366CC}[Informatie] {FFCC99}Ai extras din cont %d $. Mai ai in cont %d $. {CC66CC}***", Suma, BankInfo[playerid][pBalance]);
- SendClientMessage(playerid, 0xFFFFFF, Mesaj);
- }
- IsPlayerInRangeOfPoint(playerid, 5.0, Bancomat [3][0], Bancomat [3][1], Bancomat [3][2])
- {
- BankInfo[playerid][pBalance] += Suma;
- GivePlayerMoney(playerid, -Suma);
- new Mesaj[256];
- format(Mesaj, sizeof(Mesaj), "{CC66CC}*** {3366CC}[Informatie] {FFCC99}Ai extras din cont %d $. Mai ai in cont %d $. {CC66CC}***", Suma, BankInfo[playerid][pBalance]);
- SendClientMessage(playerid, 0xFFFFFF, Mesaj);
- }
- else
- {
- SendClientMessage(playerid, 0xFFFFFF, "{CC66CC}*** {3366CC}[Informatie] {FFCC99}Trebuie sa fii la banca sau la unul dintre bancomate sa poti folosi aceasta comanda. {CC66CC}***");
- }
- }
- else
- {
- BankInfo[playerid][pBalance] += Suma;
- GivePlayerMoney(playerid, -Suma);
- new Mesaj[256];
- format(Mesaj, sizeof(Mesaj), "{CC66CC}*** {3366CC}[Informatie] {FFCC99}Ai extras din cont %d $. Mai ai in cont %d $. {CC66CC}***", Suma, BankInfo[playerid][pBalance]);
- SendClientMessage(playerid, 0xFFFFFF, Mesaj);
- }
- return 1;
- }
- dcmd_transfer (playerid, params[])
- {
- new id;
- new Suma;
- if (sscanf(params, "dd", id, Suma)
- {
- return SendClientMessage(playerid, 0xFFFFFF, "{CC66CC}*** {3366CC}[Informatie] {FFCC99}Forma corecta este '/transfer [ID jucator]'. {CC66CC}***");
- }
- else if (!IsPlayerConnected(id))
- {
- return SendClientMessage(playerid, 0xFFFFFF, "{CC66CC}*** {3366CC}[Informatie] [FFCC99}Acest jucator nu este conectat. {CC66CC}***");
- }
- else if (Suma > BankInfo[playerid][pBalance])
- {
- return SendClientMessage(playerid, 0xFFFFFF, "{CC66CC}*** {3366CC}[Informatie] {FFCC99}Nu ai suficienti bani in cont. {CC66CC}***");
- }
- else if (BankInfo[playerid][pBank] == 0)
- {
- IsPlayerInRangeOfPoint(playerid, 5.0, Bancomat [0][0], Bancomat [0][1], Bancomat [0][2])
- {
- BankInfo[playerid][pBalance] -= Suma;
- BankInfo[id][pBalance] += Suma;
- new Mesaj[256];
- format(Mesaj, sizeof(Mesaj), "{CC66CC}*** {3366CC}[Informatie] {FFCC99}I-ai transferat %i $ jucatorului cu ID-ul %i. Mai ai in cont %i $. {CC66CC}***", Suma, id, BankInfo[playerid][pBalance]);
- SendClientMessage(playerid, 0xFFFFFF, Mesaj);
- }
- IsPlayerInRangeOfPoint(playerid, 5.0, Bancomat [1][0], Bancomat [1][1], Bancomat [1][2])
- {
- BankInfo[playerid][pBalance] -= Suma;
- BankInfo[id][pBalance] += Suma;
- new Mesaj[256];
- format(Mesaj, sizeof(Mesaj), "{CC66CC}*** {3366CC}[Informatie] {FFCC99}I-ai transferat %i $ jucatorului cu ID-ul %i. Mai ai in cont %i $. {CC66CC}***", Suma, id, BankInfo[playerid][pBalance]);
- SendClientMessage(playerid, 0xFFFFFF, Mesaj);
- }
- IsPlayerInRangeOfPoint(playerid, 5.0, Bancomat [2][0], Bancomat [2][1], Bancomat [2][2])
- {
- BankInfo[playerid][pBalance] -= Suma;
- BankInfo[id][pBalance] += Suma;
- new Mesaj[256];
- format(Mesaj, sizeof{Mesaj), "{CC66CC}*** {3366CC}[Informatie] {FFCC99}I-ai transferat %i $ jucatorului cu ID-ul %i. Mai ai in cont %i $. {CC66CC}***", Suma, id, BankInfo[playerid][pBalance]);
- SendClientMessage(playerid, 0xFFFFFF, Mesaj);
- }
- IsPlayerInRangeOfPoint(playerid, 5.0, Bancomat [3][0], Bancomat [3][1], Bancomat [3][2])
- {
- BankInfo[playerid][pBalance] -= Suma;
- BankInfo[id][pBalance] += Suma;
- new Mesaj[256];
- format(Mesaj, sizeof(Mesaj), "{CC66CC}*** {3366CC}[Informatie] {FFCC99}I-ai transferat %i $ jucatorului cu ID-ul %i. Mai ai in cont %i $. {CC66CC}***", Suma, id, BankInfo[playerod][pBalance]);
- SendClientMessage(playerid, 0xFFFFFF, Mesaj);
- }
- }
- else
- {
- SendClientMessage(playerid, 0xFFFFFF, "{CC66CC}*** {3366CC}[Informatie] {FFCC99}Trebuie sa fii la banca sau la unul dintre bancomate sa poti folosi aceasta comanda. {CC66CC}***");
- }
- return 1;
- }
- dcmd_balance (playerid, params[])
- {
- #pragma unused params
- new Nume[256];
- new Mesaj[256];
- new Balance;
- GetPlayerName(playerid, Nume, sizeof(Nume));
- Balance = BankInfo[playerid][pBalance];
- format(Mesaj, sizeof(Mesaj), "{CC66CC}*** {3366CC}[Informatie] {FFCC99}Bun venit %d. Ai %d $ in contul tau bancar. {CC66CC}***", Nume, Balance);
- SendClientMessage(playerid, 0xFFFFFF, Mesaj);
- return 1;
- }
- dcmd_exit (playerid, params[])
- {
- #pragma unused params
- if (BankInfo[playerid][pBank] == 1)
- {
- SetPlayerInterior(playerid, 0);
- SetPlayerPosiiton(palyerid, );
- BankInfo[playerid][pBank] = 0;
- }
- return 1;
- }
- // =============================================================================
- // ----------------------- Pick-up jucatorului ---------------------------------
- public OnPlayerPickup(playerid, pickupid)
- {
- if (pickupid == Banca)
- {
- SetPlayerInterior(playerid, 10);
- SetPlayerPosition(playerid, 6.091180, -29.271898, 1003.549988);
- GameTextForPlayer(playerid, "Foloseste comanda /exit pentru a parasi banca.", 5000, 3);
- BankInfo[playerid][pBank] = 1;
- }
- return 1;
- }
- // =============================================================================
- // ----------------------- Dialogul jucatorului --------------------------------
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if (dialogid == 1)
- {
- new Fisier[128];
- new Mesaj[128];
- new Nume[MAX_PLAYER_NAME];
- GetPlayerName(playerid, Nume, MAX_PLAYER_NAME);
- format(Fisier, sizeof(Fisier), ".../Conturi/%s.ini", Nume);
- if (response)
- {
- if (strlen(inputtext))
- {
- dini_Create(Fisier);
- dini_IntSet(Fisier, "pAdmin", PlayerInfo[playerid][pAdmin]);
- dini_IntSet(Fisier, "pLevel", PlayerInfo[playerid][pLevel]);
- dini_IntSet(Fisier, "pMoney", PlayerInfo[playerid][pMoney]);
- dini_IntSet(Fisier, "pPassword", num_hash(inputtext));
- format(Mesaj, sizeof(Mesaj), "{CC66CC}*** {3366CC}[Informatie] {FFCC99}Bine ai revenit. Esti conectat pe server cu contul %s. Parola contului este %s. {CC66CC}***", Nume, inputtext);
- SendClientMessage(playerid, 0xFFFFFF, Mesaj);
- PlayerInfo[playerid][pAdmin] = dini_Int(Fisier, "pAdmin");
- PlayerInfo[playerid][pLevel] = dini_Int(Fisier, "pLevel");
- PlayerInfo[playerid][pMoney] = dini_Int(Fisier, "pMoney");
- }
- }
- else
- {
- Kick(playerid);
- }
- }
- if (dialogid == 2)
- {
- new Fisier[128];
- new Nume[MAX_PLAYER_NAME];
- GetPlayerName(playerid, Nume, MAX_PLAYER_NAME);
- format(Fisier, sizeof(Fisier), ".../Conturi/%s.ini", Nume);
- if (response)
- {
- if (strlen(inputtext))
- {
- if (num_hash(inputtext) != dini_Int(Fisier, "pPassword"))
- {
- SendClientMessage(playerid, 0xFFFFFF, "{CC66CC}*** {3366CC}[Informatie] {FFCC99}Parola introdusa este incorecta. Pentru a te conecta pe server, trebuie sa introduci parola corecta in casuta de mai jos. {CC66CC}***");
- ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Fereastra de logare", "Bine ai venit pe serverul Define Roleplay. /nAcest cont este inregistrat in baza noastra de date. /nIntrodu parola corecta in casuta de mai jos pentru a te conecta pe server.", "Ok", "Renunta");
- }
- else
- {
- SendClientMessage(playerid, 0xFFFFFF, "{CC66CC}*** {3366CC][Informatie] {FFCC99}Te-ai conectat cu succes pe server. Iti dorim o distractie placuta. {CC66CC}***");
- PlayerInfo[playerid][pAdmin] = dini_Int(Fisier, "pAdmin");
- PlayerInfo[playerid][pLevel] = dini_Int(Fisier, "pLevel");
- PlayerInfo[playerid][pMoney] = dini_Int(Fisier, "pMoney");
- GivePlayerMoney(playerid, dini_Int(Fisier, "pMoney"));
- }
- }
- }
- else
- {
- Kick(playerid);
- }
- }
- return 1;
- }
- // =============================================================================
- // ---------------------------- Stockuri ---------------------------------------
- stock sscanf(string[], format[], {Float,_}:...)
- {
- new formatPos = 0;
- new stringPos = 0;
- new paramPos = 2;
- new paramCount = numargs();
- while (paramPos < paramCount && string[stringPos])
- {
- switch (format[formatPos++])
- {
- case '\0':
- {
- return 0;
- }
- case 'i', 'd':
- {
- new neg = 1;
- new num = 0;
- new ch = string[stringPos];
- if (ch == '-')
- {
- neg = -1;
- ch = string[++stringPos];
- }
- do
- {
- stringPos++;
- if (ch >= '0' && ch <= '9')
- {
- num = (num * 10) + (ch - '0');
- }
- else
- {
- return 1;
- }
- }
- while ((ch = string[stringPos]) && ch != ' ');
- setarg(paramPos, 0, num * neg);
- }
- case 'h', 'x':
- {
- new ch;
- new num = 0;
- while ((ch = string[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));
- }
- case ' ':
- {
- break;
- }
- default:
- {
- return 1;
- }
- }
- }
- setarg(paramPos, 0, num);
- }
- case 'c':
- {
- setarg(paramPos, 0, string[stringPos++]);
- }
- case 'f':
- {
- new tmp[25];
- strmid(tmp, string, stringPos, stringPos+sizeof(tmp)-2);
- setarg(paramPos, 0, _:floatstr(tmp));
- }
- case 's', 'z':
- {
- new i = 0;
- new ch;
- if (format[formatPos])
- {
- while ((ch = string[stringPos++]) && ch != ' ')
- {
- 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] != ' ')
- {
- stringPos++;
- }
- while (string[stringPos] == ' ')
- {
- stringPos++;
- }
- paramPos++;
- }
- while (format[formatPos] == 'z') formatPos++;
- return format[formatPos];
- }
- // =============================================================================
Advertisement
Add Comment
Please, Sign In to add comment