Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Dieses Script wurde von DasNeo geschrieben.
- #include <a_samp>
- #include <Dini>
- #include <ocmd>
- #define DIALOG_REGIST1 1
- #define DIALOG_LOGIN 2
- #define DIALOG_NOPW 3
- #define DIALOG_NOPW2 4
- #define DIALOG_WRONGPW 5
- #define COLOR_GRAY 0xBEBEBEFF
- #define COLOR_RED 0xFF0000FF
- #define COLOR_GREEN 0x00FF00FF
- #define COLOR_TURKIS 0x00FFE6FF
- #define COLOR_WHITE 0xFFFFFFFF
- new Text:fuehrender;
- new Float:RandomSpawn[][3] =
- {
- {1377.2893,2195.7578,9.7578},
- {1372.7399,2195.3296,9.7578},
- {1368.6169,2195.3647,9.7578},
- {1364.6364,2195.8181,9.7578},
- {1360.4471,2195.6870,9.7578},
- {1394.9082,2177.4573,9.7578},
- {1394.6724,2173.6697,9.7578},
- {1394.4272,2169.1064,9.7578},
- {1394.6779,2164.6282,9.7578},
- {1394.4634,2160.0500,9.7578}
- };
- main()
- {
- print("\n----------------------------------");
- print("--------GunGame by DasNeo-----------");
- print("----------------------------------\n");
- }
- public OnGameModeInit()
- {
- SetGameModeText("GunGame");
- AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- SetTimer("hoechstesLevel", 30000, true);
- fuehrender = TextDrawCreate(148.0,416.0,"");
- TextDrawColor(fuehrender,0xBEBEBEFF);
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- SpawnPlayer(playerid);
- SetPlayerCameraPos(playerid,123,123,123);
- SetPlayerCameraLookAt(playerid, 123.1,123.1,123.1, 1);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- new path[128];
- format(path, sizeof(path), "/accounts/%s.ini", spielerName(playerid));
- new willkommen[128];
- format(willkommen,sizeof(willkommen), "{FFA000}[#] {A0A0A0}%s ist dem Spiel beigetreten.",spielerName(playerid));
- SendClientMessageToAll(COLOR_GRAY, willkommen);
- if(!dini_Exists(path))
- {
- ShowPlayerDialog(playerid, DIALOG_REGIST1, DIALOG_STYLE_PASSWORD, "Registrierung", "Wir heissen dich herzlichst\nauf unserem Server willkommen.\nBitte geben Sie hier Ihr gewuenschtes Passwort ein:", "Weiter", "Abbrechen");
- }
- else
- {
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Geben Sie Ihr Passwort ein:", "Login", "Abbrechen");
- }
- if(GetPVarInt(playerid, "banned") == 1)
- {
- SendClientMessage(playerid, COLOR_RED, "Du wurdest von diesem Server gebannt!");
- Kick(playerid);
- }
- return 1;
- }
- forward spielerName(playerid);
- stock spielerName(playerid)
- {
- new name[128];
- GetPlayerName(playerid,name,sizeof(name));
- return name;
- }
- forward spielerLaden(playerid);
- public spielerLaden(playerid)
- {
- new path[128];
- format(path, sizeof(path), "/accounts/%s.ini", spielerName(playerid));
- SetPVarInt(playerid, "Level", dini_Int(path, "Level"));
- SetPVarInt(playerid, "Gewonnen", dini_Int(path, "Level"));
- SetPVarInt(playerid, "Auswahl", dini_Int(path, "Auswahl"));
- SetPVarInt(playerid, "banned", dini_Int(path, "banned"));
- SetPVarInt(playerid, "admin", dini_Int(path, "admin"));
- return 1;
- }
- forward spielerSpeichern(playerid);
- public spielerSpeichern(playerid)
- {
- new path[128];
- format(path,sizeof(path), "/accounts/%s.ini", spielerName(playerid));
- dini_IntSet(path, "Level", GetPVarInt(playerid,"Level"));
- dini_IntSet(path, "Gewonnen", GetPVarInt(playerid, "Gewonnen"));
- dini_IntSet(path, "Auswahl", GetPVarInt(playerid, "Auswahl"));
- dini_IntSet(path, "banned", GetPVarInt(playerid, "banned"));
- dini_IntSet(path, "admin", GetPVarInt(playerid, "admin"));
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- SetPVarInt(playerid, "Level", 0);
- spielerSpeichern(playerid);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- TextDrawShowForPlayer(playerid, fuehrender);
- TogglePlayerControllable(playerid, 1);
- spielerLaden(playerid);
- SetPlayerPos(playerid, 1377.2893,2195.7578,9.7578);
- levelUp(playerid);
- spielerSpeichern(playerid);
- new rand = random(sizeof(RandomSpawn));
- SetPlayerPos(playerid, RandomSpawn[rand][0], RandomSpawn[rand][1],RandomSpawn[rand][2]);
- return 1;
- }
- forward RoundStart();
- public RoundStart()
- {
- new path[128];
- for(new i=0; i < MAX_PLAYERS; i++)
- {
- format(path,sizeof(path), "/accounts/%.ini", spielerName(i));
- dini_IntSet(path,"Level",0);
- SetPVarInt(i, "Level",0);
- spielerSpeichern(i);
- SpawnPlayer(i);
- }
- return 1;
- }
- forward levelUp(playerid);
- public levelUp(playerid)
- {
- new path[128];
- format(path,sizeof(path), "/accounts/%s.ini", spielerName(playerid));
- switch(GetPVarInt(playerid,"Level"))
- {
- case 0:
- {
- ResetPlayerWeapons(playerid);
- GivePlayerWeapon(playerid, 22, 20000);
- }
- case 1:
- {
- ResetPlayerWeapons(playerid);
- GivePlayerWeapon(playerid, 23, 20000);
- SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 1/21.");
- }
- case 2:
- {
- ResetPlayerWeapons(playerid);
- GivePlayerWeapon(playerid, 24, 20000);
- SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 2/21.");
- }
- case 3:
- {
- ResetPlayerWeapons(playerid);
- GivePlayerWeapon(playerid, 25, 20000);
- SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 3/21.");
- }
- case 4:
- {
- ResetPlayerWeapons(playerid);
- GivePlayerWeapon(playerid, 27, 20000);
- SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 4/21.");
- }
- case 5:
- {
- ResetPlayerWeapons(playerid);
- GivePlayerWeapon(playerid, 26, 20000);
- SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 5/21.");
- }
- case 6:
- {
- ResetPlayerWeapons(playerid);
- GivePlayerWeapon(playerid, 28, 20000);
- SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 6/21.");
- }
- case 7:
- {
- ResetPlayerWeapons(playerid);
- GivePlayerWeapon(playerid, 29, 20000);
- SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 7/21.");
- }
- case 8:
- {
- ResetPlayerWeapons(playerid);
- GivePlayerWeapon(playerid, 32, 20000);
- SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 8/21.");
- }
- case 9:
- {
- ResetPlayerWeapons(playerid);
- GivePlayerWeapon(playerid, 30, 20000);
- SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 9/21.");
- }
- case 10:
- {
- ResetPlayerWeapons(playerid);
- GivePlayerWeapon(playerid, 31, 20000);
- SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 10/21.");
- }
- case 11:
- {
- ResetPlayerWeapons(playerid);
- GivePlayerWeapon(playerid, 18, 20000);
- SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 11/21.");
- }
- case 12:
- {
- ResetPlayerWeapons(playerid);
- GivePlayerWeapon(playerid, 9, 1);
- SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 12/21.");
- }
- case 13:
- {
- ResetPlayerWeapons(playerid);
- GivePlayerWeapon(playerid, 37, 20000);
- SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 13/21.");
- }
- case 14:
- {
- ResetPlayerWeapons(playerid);
- GivePlayerWeapon(playerid, 38, 20000);
- SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 14/21.");
- }
- case 15:
- {
- ResetPlayerWeapons(playerid);
- GivePlayerWeapon(playerid, 35, 20000);
- SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 15/21.");
- }
- case 16:
- {
- ResetPlayerWeapons(playerid);
- GivePlayerWeapon(playerid, 36, 20000);
- SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 16/21.");
- }
- case 17:
- {
- ResetPlayerWeapons(playerid);
- GivePlayerWeapon(playerid, 39, 20000);
- GivePlayerWeapon(playerid, 40, 1);
- SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 17/21.");
- }
- case 18:
- {
- ResetPlayerWeapons(playerid);
- GivePlayerWeapon(playerid, 41, 20000);
- SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 18/21.");
- }
- case 19:
- {
- ResetPlayerWeapons(playerid);
- GivePlayerWeapon(playerid, 42, 20000);
- SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 19/21.");
- }
- case 20:
- {
- ResetPlayerWeapons(playerid);
- GivePlayerWeapon(playerid, 4, 1);
- SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 20/21.");
- }
- case 21:
- {
- ResetPlayerWeapons(playerid);
- GivePlayerWeapon(playerid, 16, 3);
- SendClientMessage(playerid, COLOR_GREEN, "Du bist Level 21/21.");
- }
- case 22:
- {
- for(new i; i < MAX_PLAYERS; i++)
- {
- if(!IsPlayerConnected(i)) return 0;
- TogglePlayerControllable(i,0);
- for(new bra=0; bra < 6; bra++)
- {
- new nach[128];
- format(nach, sizeof(nach), "Spieler %s hat diese Runde gewonnen!", spielerName(playerid));
- SendClientMessage(playerid,COLOR_GREEN, nach);
- SetTimerEx("RoundStart", 5000, 0, "i", playerid);
- TextDrawHideForAll(fuehrender);
- }
- }
- }
- }
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- if(killerid == playerid)
- {
- SendClientMessage(playerid, COLOR_RED, "Du hast Selbstmord begangen, und hast somit ein Level verloren!");
- SetPVarInt(playerid, "Level", GetPVarInt(playerid, "Level") - 1);
- }
- if(killerid != INVALID_PLAYER_ID)
- {
- if(reason != 53 || reason != 54)
- {
- SetPVarInt(killerid,"Level", GetPVarInt(killerid, "Level") + 1);
- spielerSpeichern(killerid);
- levelUp(killerid);
- }
- }
- hoechstesLevel();
- TextDrawHideForPlayer(playerid, fuehrender);
- return 1;
- }
- forward hoechstesLevel();
- public hoechstesLevel()
- {
- new msg[128];
- new pID, temp;
- for(new i; i < MAX_PLAYERS; i++)
- {
- if((temp < GetPVarInt(i, "Level")))
- {
- temp = GetPVarInt(i, "Level"), pID = i;
- }
- }
- format(msg, sizeof(msg), "Fuehrender Spieler: %s Level: %i", spielerName(pID), temp);
- TextDrawSetString(fuehrender, msg);
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/mycommand", cmdtext, true, 10) == 0)
- {
- // Do something here
- return 1;
- }
- return 0;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerEnterRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnRconCommand(cmd[])
- {
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- return 1;
- }
- public OnPlayerObjectMoved(playerid, objectid)
- {
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- return 1;
- }
- public OnVehicleMod(playerid, vehicleid, componentid)
- {
- return 1;
- }
- public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
- {
- return 1;
- }
- public OnVehicleRespray(playerid, vehicleid, color1, color2)
- {
- return 1;
- }
- public OnPlayerSelectedMenuRow(playerid, row)
- {
- return 1;
- }
- public OnPlayerExitedMenu(playerid)
- {
- return 1;
- }
- public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
- {
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- return 1;
- }
- public OnRconLoginAttempt(ip[], password[], success)
- {
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- return 1;
- }
- public OnPlayerStreamIn(playerid, forplayerid)
- {
- return 1;
- }
- public OnPlayerStreamOut(playerid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamIn(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamOut(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- new path[128];
- format(path,sizeof(path), "/accounts/%s.ini", spielerName(playerid));
- switch(dialogid)
- {
- case DIALOG_REGIST1:
- {
- if(!response)
- {
- Kick(playerid);
- }
- else
- {
- new pwlength = strlen(inputtext);
- if(pwlength > 0)
- {
- new nachricht[238];
- format(nachricht, sizeof(nachricht), "Sie haben sich erfolgreich mit dem Namen %s registriert.", spielerName(playerid));
- dini_Create(path);
- dini_Set(path, "key", inputtext);
- dini_IntSet(path, "Level", 0);
- dini_IntSet(path, "banned", 0);
- dini_IntSet(path, "admin", 0);
- SendClientMessage(playerid, COLOR_TURKIS, nachricht);
- SendClientMessage(playerid, COLOR_TURKIS, "Das gesamte Team wünscht dir viel Spass beim spielen.");
- SendClientMessage(playerid, COLOR_TURKIS, "Solltest du Hilfe brauchen, gib /hilfe ein.");
- }
- else
- {
- ShowPlayerDialog(playerid, DIALOG_NOPW, DIALOG_STYLE_MSGBOX,"Registrierung" ,"Bitte geben Sie ein Passwort ein.", "Weiter", "Abbrechen");
- }
- }
- }
- case DIALOG_LOGIN:
- {
- if(!response)
- {
- Kick(playerid);
- }
- else
- {
- new pwlength = strlen(inputtext);
- if(pwlength > 0)
- {
- new pw[200];
- format(pw,sizeof(pw), "%s", dini_Get(path, "key"));
- if(strcmp(inputtext, pw) == 0)
- {
- spielerLaden(playerid);
- SendClientMessage(playerid, COLOR_WHITE, "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||");
- SendClientMessage(playerid, COLOR_TURKIS, "Du hast dich erfolgreich eingeloggt!");
- SendClientMessage(playerid, COLOR_TURKIS, "Wir wünschen dir viel Spass beim spielen.");
- SendClientMessage(playerid, COLOR_WHITE, "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||");
- }
- else
- {
- ShowPlayerDialog(playerid, DIALOG_WRONGPW, DIALOG_STYLE_MSGBOX, "Login", "Falsches Passwort!", "OK", "Abbrechen");
- }
- }
- else
- {
- ShowPlayerDialog(playerid, DIALOG_NOPW2, DIALOG_STYLE_MSGBOX, "Login", "Sie haben das falsche Passwort eingegeben.", "OK", "Abbrechen");
- }
- }
- }
- case DIALOG_NOPW:
- {
- if(!response)
- {
- Kick(playerid);
- }
- else
- {
- ShowPlayerDialog(playerid, DIALOG_REGIST1, DIALOG_STYLE_PASSWORD, "Registrierung", "Geben Sie hier Ihr gewuenschtes Passwort ein.", "OK", "Abbrechen");
- }
- }
- case DIALOG_NOPW2:
- {
- if(!response)
- {
- Kick(playerid);
- }
- else
- {
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Geben Sie Ihr Passwort ein.", "OK", "Abbrechen");
- }
- }
- case DIALOG_WRONGPW:
- {
- if(!response)
- {
- Kick(playerid);
- }
- else
- {
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Login", "Geben Sie hier Ihr Passwort ein.", "OK","Abbrechen");
- }
- }
- }
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- new stats[258];
- format(stats, sizeof(stats), "Spieler: %s [ID: %i], Level: %i, Spiele gewonnen: %i", spielerName(clickedplayerid), clickedplayerid, GetPVarInt(clickedplayerid, "Level"),GetPVarInt(clickedplayerid, "Gewonnen"));
- SendClientMessage(playerid, COLOR_WHITE, stats);
- return 1;
- }
- ocmd:help(playerid,params[])
- {
- SendClientMessage(playerid, COLOR_WHITE, "Was ist GunGame?");
- SendClientMessage(playerid, COLOR_GREEN, "Gungame ist ein Mod, indem du deine Gegner mit");
- SendClientMessage(playerid, COLOR_GREEN, "deiner Waffe töten musst, um eine neue Waffe zu bekommen.");
- SendClientMessage(playerid, COLOR_GREEN, "Der erste Spieler, der Level 21 erreicht, gewinnt!");
- SendClientMessage(playerid, COLOR_GREEN, "Solltest du Selbstmord begehen, verlierst du ein Level.");
- SendClientMessage(playerid, COLOR_RED, "Dieser Gamemode wurde von DasNeo gescriptet.");
- return 1;
- }
- ocmd:kick(playerid,params[])
- {
- if(GetPVarInt(playerid, "admin") == 1)
- {
- new id;
- new reason[128];
- if(sscanf(params,"us", id, reason)) return SendClientMessage(playerid, COLOR_RED, "Benutzung: /kick [ID] [Grund]");
- new sendMSG[278];
- format(sendMSG,sizeof(sendMSG), "[AdmCMD - Kick] Spieler %s wurde gekickt. Begründung: %s", spielerName(id), reason);
- SendClientMessageToAll(COLOR_RED, sendMSG);
- new printMSG[278];
- format(printMSG, sizeof(printMSG), "KICK: %s hat %s gekickt. Begründung: %s", spielerName(playerid), spielerName(id), reason);
- print(printMSG);
- Kick(id);
- }
- return 1;
- }
- ocmd:rr(playerid,params[])
- {
- if(GetPVarInt(playerid, "admin") == 1)
- {
- new sendMSG[278];
- format(sendMSG,sizeof(sendMSG), "[AdmCMD - RoundRestart] Admin %s hat die Runde neu gestartet.", spielerName(playerid));
- SendClientMessageToAll(COLOR_RED, sendMSG);
- new printMSG[278];
- format(printMSG, sizeof(printMSG), "RR: %s hat die Runde neu gestartet.", spielerName(playerid));
- print(printMSG);
- }
- return 1;
- }
- ocmd:ban(playerid,params[])
- {
- if(GetPVarInt(playerid, "admin") == 1)
- {
- new id;
- new reason[128];
- if(sscanf(params,"us", id, reason)) return SendClientMessage(playerid, COLOR_RED, "Benutzung: /ban [ID] [Grund]");
- new sendMSG[278];
- format(sendMSG,sizeof(sendMSG), "[AdmCMD - Ban] Spieler %s wurde gekickt. Begründung: %s", spielerName(id), reason);
- SendClientMessageToAll(COLOR_RED, sendMSG);
- new printMSG[278];
- format(printMSG, sizeof(printMSG), "BAN: %s hat %s gekickt. Begründung: %s", spielerName(playerid), spielerName(id), reason);
- print(printMSG);
- SetPVarInt(id, "banned", 1);
- spielerSpeichern(id);
- }
- 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement