Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ..:: Easy Adminstration 1.1 Script by Hustler ::..
- >> PLEASE do NOT take out the credits (c)
- >> It`s a very simple Admin System for a simple Gamemode
- ..:: CREDITS ::..
- >> BlackFoX_UD_(BfX) - For the graet Login TUT ! in www.samp.breadfish.de
- >> Golkiller - For dcmd + sscanf Tutorial in www.samp.breadfish.de
- >> DracoBlue - For dcmd
- >> Alex aka Y_Less - For sscanf
- >> www.samp.breadfish.de - For the nice Community which help always
- >> Hustler - For The Admin script ;D
- ..:: I wish you much fun with the filterscript ::..
- */
- // SRY FOR MY BAD ENGLISH <3
- #include <a_samp>
- #include <dini>
- #define DIALOG_LOGIN 3
- #define DIALOG_REG 4
- #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 COLOR_GREY 0xAFAFAFAA
- #define COLOR_GREEN 0x33AA33AA
- #define COLOR_RED 0xFF0000AA
- #define COLOR_BLUE 0x0000BBAA
- #define COLOR_LIGHTBLUE 0x33CCFFAA
- #define COLOR_DARKRED 0x660000AA
- #define COLOR_WHITE 0xFFFFFFAA
- #define COLOR_YELLOW 0xF1FE01FF
- #define COLOR_PURPLE 0x9E18E7FF
- enum Player_daten
- {
- admin,
- Deaths,
- Kills,
- eingeloggt
- }
- new Player[MAX_PLAYERS][Player_daten];
- //----
- new Text:StatsTextdraw[MAX_PLAYERS];
- forward StatsTimer();
- new Text:Easy[MAX_PLAYERS];
- //----
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print("*** EASY ADMINISTRATION 1.1 FILTERSCRIPT *** by HustLeR");
- print(" LOADED ");
- print("--------------------------------------\n");
- SetTimer("StatsTimer",1500,1);
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- new pname[MAX_PLAYERS],accFormat[128];
- GetPlayerName(playerid,pname,sizeof pname);
- format(accFormat,sizeof accFormat,"acc/%s.sav",pname);
- if(fexist(accFormat))
- {
- ShowPlayerDialog(playerid,DIALOG_LOGIN,1,"Login","Please logg in ","Cancel","Next");
- }
- else
- {
- ShowPlayerDialog(playerid,DIALOG_REG,1,"Register","Please register to keep your stats","Cancel","Next");
- }
- SendClientMessage(playerid,COLOR_RED,"This Server is running on Husler`s Easy Administration Script");
- //----
- StatsTextdraw[playerid]= TextDrawCreate(132.000000, 418.000000, "----");
- TextDrawBackgroundColor(StatsTextdraw[playerid], 255);
- TextDrawFont(StatsTextdraw[playerid], 1);
- TextDrawLetterSize(StatsTextdraw[playerid], 0.529999, 1.900000);
- TextDrawColor(StatsTextdraw[playerid], 869072810);
- TextDrawSetOutline(StatsTextdraw[playerid], 1);
- TextDrawSetProportional(StatsTextdraw[playerid], 1);
- //-----
- Easy[playerid] = TextDrawCreate(0.000000, 440.000000, "Easy Administration");
- TextDrawBackgroundColor(Easy[playerid], 255);
- TextDrawFont(Easy[playerid], 1);
- TextDrawLetterSize(Easy[playerid], 0.200000, 0.899999);
- TextDrawColor(Easy[playerid], 869072810);
- TextDrawSetOutline(Easy[playerid], 1);
- TextDrawSetProportional(Easy[playerid], 1);
- TextDrawShowForPlayer(playerid,Easy[playerid]);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new pname[MAX_PLAYERS],accFormat[128];
- GetPlayerName(playerid,pname,sizeof pname);
- format(accFormat,sizeof accFormat,"acc/%s.sav",pname);
- if(fexist(accFormat) && Player[playerid][eingeloggt])
- {
- dini_IntSet(accFormat,"Adminlvl",Player[playerid][admin]);
- dini_IntSet(accFormat,"Kills",Player[playerid][Kills]);
- dini_IntSet(accFormat,"Deaths",Player[playerid][Deaths]);
- dini_IntSet(accFormat,"Geld",GetPlayerMoney(playerid));
- dini_IntSet(accFormat,"Score",GetPlayerScore(playerid));
- }
- Player[playerid][eingeloggt] = 0;
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- Player[playerid][Deaths]++;
- Player[killerid][Kills]++;
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- new pname[MAX_PLAYERS],accFormat[128];
- GetPlayerName(playerid,pname,sizeof pname);
- format(accFormat,sizeof accFormat,"acc/%s.sav",pname);
- if(response)
- {
- switch(dialogid)
- {
- case DIALOG_LOGIN: // ID Login
- {
- if(!strlen(inputtext))
- {
- ShowPlayerDialog(playerid,DIALOG_LOGIN,1,"Login","Please logg in ","Cancel","Next");
- return SendClientMessage(playerid,0xFFFFFFFF,"No password!");
- }
- if(strcmp(inputtext,dini_Get(accFormat,"Passwort")) == 0) // Load PSW
- {
- Player[playerid][admin] = dini_Int(accFormat,"AdminLvl");
- Player[playerid][Kills] = dini_Int(accFormat,"Kills");
- Player[playerid][Deaths] = dini_Int(accFormat,"Deaths");
- GivePlayerMoney(playerid,dini_Int(accFormat,"Geld"));
- SetPlayerScore(playerid,dini_Int(accFormat,"Score"));
- Player[playerid][eingeloggt] = 1; //player is logged in now
- SendClientMessage(playerid,0xFFFFFFFF,"You have been sucessfully logged in.");
- }
- else
- {
- ShowPlayerDialog(playerid,DIALOG_LOGIN,1,"Login","Please logg in","Cancel","Next");
- SendClientMessage(playerid,0xFFFFFFFF,"This password ist wrong!");
- }
- }
- case DIALOG_REG:
- {
- if(!strlen(inputtext))
- {
- ShowPlayerDialog(playerid,DIALOG_REG,1,"Register","Please register to keep your stats","Cancel","Next");
- return SendClientMessage(playerid,0xFFFFFFFF,"This password ist too short!");
- }
- dini_Create(accFormat);
- dini_Set(accFormat,"Passwort",inputtext);
- Player[playerid][admin] = 0 ;
- Player[playerid][eingeloggt] = 1;
- SendClientMessage(playerid,0xFFFFFFFF,"Yout account has been registred and you have been automatically logged in");
- }
- }
- }
- else
- {
- switch(dialogid)
- {
- case DIALOG_LOGIN:ShowPlayerDialog(playerid,DIALOG_LOGIN,1,"Login","Please logg in","Cancel","Next");
- case DIALOG_REG:ShowPlayerDialog(playerid,DIALOG_REG,1,"Register","Please register to keep yout stats","Cancel","Next");
- }
- }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- //-------------------DCMD`s Begin---------------------------------------------------------
- dcmd(report,6,cmdtext);
- dcmd(kick,4,cmdtext);
- dcmd(ban,3,cmdtext);
- dcmd(seestats,8,cmdtext);
- dcmd(admins,6,cmdtext);
- dcmd(a,1,cmdtext);
- dcmd(dec,3,cmdtext);
- dcmd(makeadmin,9,cmdtext);
- dcmd(freeze,6,cmdtext);
- dcmd(unfreeze,8,cmdtext);
- dcmd(setkills,8,cmdtext);
- dcmd(setdeaths,9,cmdtext);
- dcmd(setscore,8,cmdtext);
- dcmd(givecash,8,cmdtext);
- dcmd(giveweapon,10,cmdtext);
- dcmd(explode,7,cmdtext);
- dcmd(tele,4,cmdtext);
- dcmd(gethere,7,cmdtext);
- dcmd(pm,2,cmdtext);
- dcmd(setskin,7,cmdtext);
- dcmd(sethealth,9,cmdtext);
- dcmd(takeweaps,9,cmdtext);
- dcmd(changeweather,13,cmdtext);
- dcmd(sethour,7,cmdtext);
- dcmd(veh,3,cmdtext);
- dcmd(seecash,7,cmdtext);
- dcmd(setcash,7,cmdtext);
- dcmd(setarm,6,cmdtext);
- //----------------------Dcmd`s END------------------------------------------------------------
- if(strcmp("/cmd",cmdtext,true,10)==0){
- SendClientMessage(playerid,COLOR_RED,"[USER CMD`s] : /stats /seestats /resetstats /pm /admins /report /ahelp");
- return 1;
- }
- if(strcmp("/credits",cmdtext,true,10)==0){
- SendClientMessage(playerid,COLOR_RED,"Easy Administration Script by Hustler (c)");
- return 1;
- }
- if (strcmp("/clear", cmdtext, true, 10) == 0)
- {
- if(Player[playerid][admin] < 1)
- {
- SendClientMessage(playerid, COLOR_RED,"You must be a Moderator or higher to see clear the chat");
- }
- for(new i=0;i<100;i++){
- SendClientMessageToAll(COLOR_RED," ");
- }
- new name[MAX_PLAYER_NAME],string[128];
- GetPlayerName(playerid,name,sizeof(name));
- format(string,sizeof(string),"Admin %s has cleared the chat",name);
- SendClientMessageToAll(COLOR_GREEN,string);
- return 1;
- }
- if (strcmp("/ahelp", cmdtext, true, 10) == 0)
- {
- if(Player[playerid][admin] == 0)
- {
- SendClientMessage(playerid, COLOR_RED,"You must be a Moderator or higher to see admin commands");
- }
- if(Player[playerid][admin] == 1)
- {
- SendClientMessage(playerid, COLOR_PURPLE,"[ModeratorCMD`s]: /a /dec /freeze /unfreeze /explode /kick /takeweaps /clear /seecash");
- }
- if(Player[playerid][admin] == 2)
- {
- SendClientMessage(playerid, COLOR_PURPLE,"[ModeratorCMD`s]: /a /dec /freeze /unfreeze /explode /kick /takeweaps /clear /seecash");
- SendClientMessage(playerid, COLOR_PURPLE,"[AdminCMD`s]: /giveweapon /tele /gethere /setskin /sethealth /sethour /setarm /changeweather");
- }
- if(Player[playerid][admin] == 3)
- {
- SendClientMessage(playerid, COLOR_PURPLE,"[ModeratorCMD`s]: /a /dec /freeze /unfreeze /explode /kick /takeweaps /clear /seecash");
- SendClientMessage(playerid, COLOR_PURPLE,"[AdminCMD`s]: /giveweapon /tele /gethere /setskin /sethealth /setarm /sethour /changeweather");
- SendClientMessage(playerid, COLOR_PURPLE,"[SuperAdminCMD`s]: /gmx /ban /setscore /setdeaths /setkills /givecash /setcash /veh");
- }
- if(Player[playerid][admin] == 4)
- {
- SendClientMessage(playerid, COLOR_PURPLE,"[ModeratorCMD`s]: /a /dec /freeze /unfreeze /explode /kick /takeweaps /clear /seecash");
- SendClientMessage(playerid, COLOR_PURPLE,"[AdminCMD`s]: /giveweapon /tele /gethere /setskin /sethealth /setarm /sethour /changeweather");
- SendClientMessage(playerid, COLOR_PURPLE,"[SuperAdminCMD`s]: /gmx /ban /setscore /setdeaths /setkills /givecash /setcash /veh");
- SendClientMessage(playerid, COLOR_PURPLE,"[ServerOwnerCMD`s]: /makeadmin");
- }
- return 1;
- }
- if (strcmp("/stats", cmdtext, true, 10) == 0)
- {
- new name[MAX_PLAYER_NAME], string[256], string2[256],string3[256];
- GetPlayerName(playerid, name, sizeof(name));
- format(string, sizeof(string), "| Stats of[%s] |", name);
- format(string2, sizeof(string2), "[Kills: %d] [Deaths: %d] [Ratio: %0.2f] ",Player[playerid][Kills], Player[playerid][Deaths],Float:Player[playerid][Kills]/Float:Player[playerid][Deaths]);
- format(string3, sizeof(string3), "[Cash: %d] [Score: %d] [Adminlevel: %d]",GetPlayerMoney(playerid),GetPlayerScore(playerid),Player[playerid][admin]);
- SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
- SendClientMessage(playerid, COLOR_WHITE, string2);
- SendClientMessage(playerid, COLOR_WHITE, string3);
- SendClientMessage(playerid, COLOR_LIGHTBLUE, "|__________________________________________|");
- return 1;
- }
- if (strcmp("/gmx",cmdtext,true,10) == 0)
- {
- if(Player[playerid][admin] < 3){
- return SendClientMessage(playerid,COLOR_RED,"You must be Admin level 3 or higher to start a gmx");
- }
- new
- name[MAX_PLAYER_NAME],
- string[128];
- GetPlayerName(playerid,name,sizeof(name));
- format(string,sizeof(string),"Admin %s has restarted the sesrver!",name);
- SendClientMessageToAll(COLOR_LIGHTBLUE,string);
- SendRconCommand("gmx");
- return 1;
- }
- if (strcmp("/resetstats", cmdtext, true, 10) == 0)
- {
- Player[playerid][Deaths]=0;
- Player[playerid][Kills]=0;
- SetPlayerScore(playerid,0);
- SendClientMessage(playerid,COLOR_YELLOW,"You have reset your stats");
- return 1;
- }
- return 0;
- }
- //=============================================================DCMD`s Commands=================================================
- dcmd_report(playerid,params[])
- {
- new
- sReason[128],
- pID;
- if(sscanf(params,"ds",pID,sReason)) {
- return SendClientMessage(playerid,COLOR_RED,"USAGE: /report [playerid] [reason]");
- }
- if(!IsPlayerConnected(pID)) {
- return SendClientMessage(playerid,COLOR_RED,"Nobody is connected with this ID");
- }
- new
- Tplayer[MAX_PLAYER_NAME],
- string[128];
- GetPlayerName(pID,Tplayer,sizeof(Tplayer));
- format(string,sizeof(string),"%s has reported (ID %d) with the reason: %s",Tplayer,pID,sReason[0] ? sReason : "<No Reason>");
- SendAdminMessage(COLOR_YELLOW,string);
- return 1;
- }
- dcmd_kick(playerid,params[])
- {
- new
- Reason[256],
- pID;
- if(Player[playerid][admin] < 1){
- return SendClientMessage(playerid,COLOR_RED,"You are not a Moderator/Admin!");
- }
- if(sscanf(params,"us",pID,Reason)){
- return SendClientMessage(playerid,COLOR_RED,"USAGE: /kick [playerid] [reason]");
- }
- if(!IsPlayerConnected(pID)) {
- return SendClientMessage(playerid,COLOR_RED,"Nobody is connected with this ID!");
- }
- if(Player[playerid][admin] < Player[pID][admin]){
- return SendClientMessage(playerid,COLOR_RED,"You can`t kick a high ranked admin");
- }
- new
- name[MAX_PLAYER_NAME],
- string[256];
- GetPlayerName(pID,name,sizeof(name));
- new
- Aname[MAX_PLAYER_NAME];
- GetPlayerName(playerid,Aname,sizeof(Aname));
- format(string,sizeof(string)," %s has kicked %s with the reason: %s",Aname,name,Reason);
- SendClientMessageToAll(COLOR_GREEN,string);
- Kick(pID);
- return 1;
- }
- dcmd_ban(playerid,params[])
- {
- new
- Reason[256],
- pID;
- if(Player[playerid][admin] < 3){
- return SendClientMessage(playerid,COLOR_RED,"You are not a Admin!");
- }
- if(sscanf(params,"us",pID,Reason)){
- return SendClientMessage(playerid,COLOR_RED,"USAGE: /ban [playerid] [reason]");
- }
- if(!IsPlayerConnected(pID)) {
- return SendClientMessage(playerid,COLOR_RED,"Nobody is connected with this ID!");
- }
- if(Player[playerid][admin] < Player[pID][admin]){
- return SendClientMessage(playerid,COLOR_RED,"You can`t ban a high ranked admin");
- }
- new
- name[MAX_PLAYER_NAME],
- string[256];
- GetPlayerName(pID,name,sizeof(name));
- new
- Aname[MAX_PLAYER_NAME];
- GetPlayerName(playerid,Aname,sizeof(Aname));
- format(string,sizeof(string)," %s has banned %s with the reason: %s",Aname,name,Reason);
- SendClientMessageToAll(COLOR_GREEN,string);
- Ban(pID);
- return 1;
- }
- dcmd_seestats(playerid,params[])
- {
- new pID;
- if(sscanf(params,"u",pID)){
- return SendClientMessage(playerid,COLOR_RED,"USAGE: /seestats [playerid]");
- }
- if(!IsPlayerConnected(pID)) {
- return SendClientMessage(playerid,COLOR_RED,"Nobody is connected with this ID!");
- }
- new
- name[MAX_PLAYER_NAME],
- string[256],string2[256];
- GetPlayerName(pID,name,sizeof(name));
- format(string, sizeof(string), "| Stats of[%s] |", name);
- format(string2, sizeof(string2), "[Kills: %d] [Deaths: %d] [Ratio: %0.2f] [Score: %d] ", Player[pID][Kills], Player[pID][Deaths],Float:Player[pID][Kills]/Float:Player[pID][Deaths],GetPlayerScore(pID));
- SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
- SendClientMessage(playerid,COLOR_WHITE,string2);
- SendClientMessage(playerid,COLOR_LIGHTBLUE,"|_____________________________________________|");
- new
- pname[MAX_PLAYER_NAME],string3[256];
- GetPlayerName(playerid,pname,sizeof(pname));
- format(string3, sizeof(string3), "%s has typed /seestas to see your stats", pname);
- SendClientMessage(pID,COLOR_YELLOW,string3);
- return 1;
- }
- dcmd_admins(playerid,params[])
- {
- #pragma unused params
- SendClientMessage(playerid, COLOR_BLUE, "Mods/Admins Online:");
- new i = 0, aname[256], string[256];
- for(; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(Player[i][admin] == 1)
- {
- GetPlayerName(i, aname, sizeof(aname));
- format(string, 256, " Moderator: %s", aname);
- SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
- }
- else if(Player[i][admin] == 2)
- {
- GetPlayerName(i, aname, sizeof(aname));
- format(string, 256, " Admin: %s", aname);
- SendClientMessage(playerid, COLOR_LIGHTBLUE, aname);
- }
- else if(Player[i][admin] == 3)
- {
- GetPlayerName(i, aname, sizeof(aname));
- format(string, 256, " SuperAdmin: %s", aname);
- SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
- }
- else if(Player[i][admin] == 4)
- {
- GetPlayerName(i, aname, sizeof(aname));
- format(string, 256, " ServerOwner: %s", aname);
- SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
- }
- }
- }
- return 1;
- }
- dcmd_a(playerid,params[])
- {
- if(Player[playerid][admin] <= 1) {
- return SendClientMessage(playerid,COLOR_RED,"You must be a Mod/Admin to be able to write in admin chat");
- }
- new atext[128];
- if(sscanf(params,"s",atext)){
- return SendClientMessage(playerid,COLOR_RED,"USAGE: /a [text]");
- }
- new name[MAX_PLAYER_NAME];
- new string[128];
- GetPlayerName(playerid,name,sizeof(name));
- format(string,sizeof(string),"Level %d Admin (%s): %s" ,Player[playerid][admin],name,atext);
- SendAdminMessage(COLOR_YELLOW,string);
- return 1;
- }
- dcmd_dec(playerid,params[])
- {
- new dtext[128];
- if(Player[playerid][admin] <=1) {
- return SendClientMessage (playerid,COLOR_RED,"You must be a Mod/Admin to write a declaration");
- }
- if(sscanf(params,"s",dtext)){
- return SendClientMessage(playerid,COLOR_RED,"USAGE: /dec [text]");
- }
- GameTextForAll(dtext,3*1000,3);
- return 1;
- }
- dcmd_makeadmin(playerid,params[])
- {
- if(Player[playerid][admin] == 4 || IsPlayerAdmin(playerid)) {}
- new pID,alevel;
- if(sscanf(params,"ud",pID,alevel)){
- return SendClientMessage (playerid,COLOR_RED,"USAGE: /makeadmin [playerid] [adminlevel]");
- }
- if(!IsPlayerConnected(pID)){
- return SendClientMessage (playerid,COLOR_RED,"Nobody is connected with this ID!");
- }
- new string[128],string2[128],aname[MAX_PLAYER_NAME],name[MAX_PLAYER_NAME];
- Player[pID][admin] = alevel;
- GetPlayerName(playerid,aname,sizeof(aname));
- GetPlayerName(pID,name,sizeof(name));
- format(string,sizeof(string),"You have set the admin level of %s to %d",name,alevel);
- format(string2,sizeof(string2),"ServerOwner %s has set your admin level to %d",aname,alevel);
- SendClientMessage(playerid,COLOR_GREEN,string);
- SendClientMessage(pID,COLOR_GREEN,string2);
- return 1;
- }
- dcmd_freeze(playerid,params[])
- {
- if(Player[playerid][admin] < 1){
- return SendClientMessage (playerid,COLOR_RED,"You must be a Mod/Admin to freeze Players");
- }
- new pID;
- if(sscanf(params,"u",pID)){
- return SendClientMessage(playerid,COLOR_RED,"USAGE: /freeze [playerid]");
- }
- if(!IsPlayerConnected(pID)){
- return SendClientMessage(playerid,COLOR_RED,"Nobody is connected with this ID!");
- }
- if(Player[playerid][admin] < Player[pID][admin]){
- return SendClientMessage(playerid,COLOR_RED,"You can`t freeze a high ranked admin");
- }
- new string[128],string2[128],adminname[MAX_PLAYER_NAME],name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,adminname,sizeof(adminname));
- GetPlayerName(pID,name,sizeof(name));
- format(string,sizeof(string),"You have frozen %s",name);
- format(string2,sizeof(string2),"You was been frozen by %s",adminname);
- SendClientMessage(playerid,COLOR_GREEN,string);
- SendClientMessage(pID,COLOR_GREEN,string2);
- TogglePlayerControllable(pID, 0);
- return 1;
- }
- dcmd_unfreeze(playerid,params[])
- {
- if(Player[playerid][admin] < 1){
- return SendClientMessage (playerid,COLOR_RED,"You must be a Mod/Admin to freeze Players");
- }
- new pID;
- if(sscanf(params,"u",pID)){
- return SendClientMessage(playerid,COLOR_RED,"USAGE: /freeze [playerid]");
- }
- if(!IsPlayerConnected(pID)){
- return SendClientMessage(playerid,COLOR_RED,"Nobody is connected with this ID!");
- }
- new string[128],string2[128],adminname[MAX_PLAYER_NAME],name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,adminname,sizeof(adminname));
- GetPlayerName(pID,name,sizeof(name));
- format(string,sizeof(string),"You have unfrozen %s",name);
- format(string2,sizeof(string2),"You was been unfrozen by %s",adminname);
- SendClientMessage(playerid,COLOR_GREEN,string);
- SendClientMessage(pID,COLOR_GREEN,string2);
- TogglePlayerControllable(pID, 1);
- return 1;
- }
- dcmd_setkills(playerid,params[])
- {
- if(Player[playerid][admin] < 3){
- return SendClientMessage (playerid,COLOR_RED,"You must be a SuperAdmin or ServerOwner to set Kills");
- }
- new pID,kills;
- if(sscanf(params,"ud",pID,kills)){
- return SendClientMessage(playerid,COLOR_RED,"USAGE: /setkills [playerid] [kills]");
- }
- if(!IsPlayerConnected(pID)){
- return SendClientMessage(playerid,COLOR_RED,"Nobody is connected with this ID!");
- }
- if(Player[playerid][admin] < Player[pID][admin]){
- return SendClientMessage(playerid,COLOR_RED,"You can`t set the kills of a high ranked admin");
- }
- new string[128],string2[128],aname[MAX_PLAYER_NAME],name[MAX_PLAYER_NAME];
- Player[pID][Kills] = kills;
- GetPlayerName(playerid,aname,sizeof(aname));
- GetPlayerName(pID,name,sizeof(name));
- format(string,sizeof(string),"You have set the kills of %s to %d",name,kills);
- format(string2,sizeof(string2),"Admin %s has set your kills to %d",aname,kills);
- SendClientMessage(playerid,COLOR_GREEN,string);
- SendClientMessage(pID,COLOR_GREEN,string2);
- return 1;
- }
- dcmd_setdeaths(playerid,params[])
- {
- if(Player[playerid][admin] < 3){
- return SendClientMessage (playerid,COLOR_RED,"You must be a SuperAdmin or ServerOwner to set Deaths");
- }
- new pID,deaths;
- if(sscanf(params,"ud",pID,deaths)){
- return SendClientMessage(playerid,COLOR_RED,"USAGE: /setkills [playerid] [kills]");
- }
- if(!IsPlayerConnected(pID)){
- return SendClientMessage(playerid,COLOR_RED,"Nobody is connected with this ID!");
- }
- if(Player[playerid][admin] < Player[pID][admin]){
- return SendClientMessage(playerid,COLOR_RED,"You can`t set the deaths of a high ranked admin");
- }
- new string[128],string2[128],aname[MAX_PLAYER_NAME],name[MAX_PLAYER_NAME];
- Player[pID][Deaths] = deaths;
- GetPlayerName(playerid,aname,sizeof(aname));
- GetPlayerName(pID,name,sizeof(name));
- format(string,sizeof(string),"You have set the Deaths of %s to %d",name,deaths);
- format(string2,sizeof(string2),"Admin %s has set your Deaths to %d",aname,deaths);
- SendClientMessage(playerid,COLOR_GREEN,string);
- SendClientMessage(pID,COLOR_GREEN,string2);
- return 1;
- }
- dcmd_setscore(playerid,params[])
- {
- if(Player[playerid][admin] < 3){
- return SendClientMessage (playerid,COLOR_RED,"You must be a SuperAdmin or ServerOwner to set Scores");
- }
- new pID,scores;
- if(sscanf(params,"ud",pID,scores)){
- return SendClientMessage(playerid,COLOR_RED,"USAGE: /setscore [playerid] [score]");
- }
- if(!IsPlayerConnected(pID)){
- return SendClientMessage(playerid,COLOR_RED,"Nobody is connected with this ID!");
- }
- if(Player[playerid][admin] < Player[pID][admin]){
- return SendClientMessage(playerid,COLOR_RED,"You can`t set the score of a high ranked admin");
- }
- new string[128],string2[128],aname[MAX_PLAYER_NAME],name[MAX_PLAYER_NAME];
- SetPlayerScore(pID,scores);
- GetPlayerName(playerid,aname,sizeof(aname));
- GetPlayerName(pID,name,sizeof(name));
- format(string,sizeof(string),"You have set the Score of %s to %d",name,scores);
- format(string2,sizeof(string2),"Admin %s has set your Score to %d",aname,scores);
- SendClientMessage(playerid,COLOR_GREEN,string);
- SendClientMessage(pID,COLOR_GREEN,string2);
- return 1;
- }
- dcmd_givecash(playerid,params[])
- {
- if(Player[playerid][admin] < 3){
- return SendClientMessage (playerid,COLOR_RED,"You must be a SuperAdmin or a ServerOwner to give money");
- }
- new pID,cash;
- if(sscanf(params,"ud",pID,cash)){
- return SendClientMessage(playerid,COLOR_RED,"USAGE: /givecash [playerid] [amount]");
- }
- if(!IsPlayerConnected(pID)){
- return SendClientMessage(playerid,COLOR_RED,"Nobody is connected with this ID!");
- }
- new string[128],string2[128],aname[MAX_PLAYER_NAME],name[MAX_PLAYER_NAME];
- GivePlayerMoney(pID,cash);
- GetPlayerName(playerid,aname,sizeof(aname));
- GetPlayerName(pID,name,sizeof(name));
- format(string,sizeof(string),"You have given Money to %s to %d",name,cash);
- format(string2,sizeof(string2),"Admin %s has given you %d $",aname,cash);
- SendClientMessage(playerid,COLOR_GREEN,string);
- SendClientMessage(pID,COLOR_GREEN,string2);
- return 1;
- }
- dcmd_giveweapon(playerid,params[])
- {
- if(Player[playerid][admin] < 2){
- return SendClientMessage (playerid,COLOR_RED,"You must be a Admin or higher to give weapons");
- }
- new pID,weapon,ammo;
- if(sscanf(params,"udd",pID,weapon,ammo)){
- return SendClientMessage(playerid,COLOR_RED,"USAGE: /giveweapon [playerid][weaponID] [ammo]");
- }
- if(!IsPlayerConnected(pID)){
- return SendClientMessage(playerid,COLOR_RED,"Nobody is connected with this ID!");
- }
- new string[128],string2[128],aname[MAX_PLAYER_NAME],name[MAX_PLAYER_NAME];
- GivePlayerWeapon(pID,weapon,ammo);
- GetPlayerName(playerid,aname,sizeof(aname));
- GetPlayerName(pID,name,sizeof(name));
- format(string,sizeof(string),"You have given the player %s weapon ID:%d with %d ammo",name,weapon,ammo);
- format(string2,sizeof(string2),"Admin %s has give you weapon ID:%d with %d ammo",aname,weapon,ammo);
- SendClientMessage(playerid,COLOR_GREEN,string);
- SendClientMessage(pID,COLOR_GREEN,string2);
- return 1;
- }
- dcmd_explode(playerid,params[])
- {
- if(Player[playerid][admin] < 1){
- return SendClientMessage (playerid,COLOR_RED,"You must be a Moderator or higher to explode players");
- }
- new pID;
- if(sscanf(params,"u",pID)){
- return SendClientMessage (playerid,COLOR_RED,"USAGE: /explode [playerid]");
- }
- if(!IsPlayerConnected(pID)){
- return SendClientMessage (playerid,COLOR_RED,"Nobody is connected with this ID!");
- }
- if(Player[playerid][admin] < Player[pID][admin]){
- return SendClientMessage(playerid,COLOR_RED,"You can`t explode a high ranked admin");
- }
- new string[128],string2[128],aname[MAX_PLAYER_NAME],name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,aname,sizeof(aname));
- GetPlayerName(pID,name,sizeof(name));
- format(string,sizeof(string),"You have explode %s ",name);
- format(string2,sizeof(string2),"Admin %s has explode you",aname);
- new Float:x,Float:y,Float:z;
- GetPlayerPos(pID,x,y,z);
- CreateExplosion(x,y,z,7,15);
- CreateExplosion(x,y,z,7,15);
- CreateExplosion(x,y,z,7,15);
- CreateExplosion(x,y,z,7,15);
- CreateExplosion(x,y,z,7,15);
- SendClientMessage(playerid,COLOR_GREEN,string);
- SendClientMessage(pID,COLOR_GREEN,string2);
- return 1;
- }
- dcmd_tele(playerid,params[])
- {
- if(Player[playerid][admin] < 2){
- return SendClientMessage (playerid,COLOR_RED,"You must be a Admin or higher to teleport to players");
- }
- new pID;
- if(sscanf(params,"u",pID)){
- return SendClientMessage (playerid,COLOR_RED,"USAGE: /tele [playerid]");
- }
- if(!IsPlayerConnected(pID)){
- return SendClientMessage (playerid,COLOR_RED,"Nobody is connected with this ID!");
- }
- new string[128],name[MAX_PLAYER_NAME];
- GetPlayerName(pID,name,sizeof(name));
- format(string,sizeof(string),"You have been teleported to %s",name);
- new Float:x,Float:y,Float:z;
- GetPlayerPos(pID,x,y,z);
- SetPlayerPos(playerid,x,y,z);
- SendClientMessage(playerid,COLOR_GREEN,string);
- return 1;
- }
- dcmd_gethere(playerid,params[])
- {
- if(Player[playerid][admin] < 2){
- return SendClientMessage (playerid,COLOR_RED,"You must be a Admin to teleport players ");
- }
- new pID;
- if(sscanf(params,"u",pID)){
- return SendClientMessage (playerid,COLOR_RED,"USAGE: /gethere [playerid]");
- }
- if(!IsPlayerConnected(pID)){
- return SendClientMessage (playerid,COLOR_RED,"Nobody is connected with this ID!");
- }
- if(Player[playerid][admin] < Player[pID][admin]){
- return SendClientMessage(playerid,COLOR_RED,"You can`t use this cmd on a high ranked admin");
- }
- new string[128],string2[128],aname[MAX_PLAYER_NAME],name[MAX_PLAYER_NAME];
- GetPlayerName(pID,name,sizeof(name));
- GetPlayerName(playerid,aname,sizeof(aname));
- format(string,sizeof(string),"You have been teleported to %s",aname);
- format(string2,sizeof(string2),"You have been teleported to %s",name);
- new Float:x,Float:y,Float:z;
- GetPlayerPos(playerid,x,y,z);
- SetPlayerPos(pID,x,y,z);
- SendClientMessage(pID,COLOR_GREEN,string);
- SendClientMessage(playerid,COLOR_GREEN,string2);
- return 1;
- }
- dcmd_pm(playerid,params[])
- {
- new
- pmtext[128],
- pID;
- if(sscanf(params,"ds",pID,pmtext)) {
- return SendClientMessage(playerid,COLOR_RED,"USAGE: /pm [playerid] [text]");
- }
- if(!IsPlayerConnected(pID)) {
- return SendClientMessage(playerid,COLOR_RED,"Nobody is connected with this ID");
- }
- new
- name[MAX_PLAYER_NAME],pmname[MAX_PLAYER_NAME],
- string[128],string2[128];
- GetPlayerName(playerid,name,sizeof(name));
- GetPlayerName(pID,pmname,sizeof(pmname));
- format(string,sizeof(string),"PM from %s : %s ",name,pmtext);
- format(string2,sizeof(string2),"You have sent the PM to %s ",pmname);
- SendClientMessage(pID,COLOR_YELLOW,string);
- SendClientMessage(playerid,COLOR_YELLOW,string2);
- return 1;
- }
- dcmd_setskin(playerid,params[])
- {
- if(Player[playerid][admin] < 2){
- return SendClientMessage (playerid,COLOR_RED,"You must be a Admin or higher to set Skins");
- }
- new pID,skinid;
- if(sscanf(params,"ud",pID,skinid)){
- return SendClientMessage(playerid,COLOR_RED,"USAGE: /setskin [playerid] [skinID(0-299!)]*");
- }
- if(!IsPlayerConnected(pID)){
- return SendClientMessage(playerid,COLOR_RED,"Nobody is connected with this ID!");
- }
- if(skinid < 0){
- return SendClientMessage(playerid,COLOR_RED,"INVALID ID!");
- }
- if(skinid > 299){
- return SendClientMessage(playerid,COLOR_RED,"INVALID ID!");
- }
- if(Player[playerid][admin] < Player[pID][admin]){
- return SendClientMessage(playerid,COLOR_RED,"You can`t use this dm a high ranked admin");
- }
- new string[128],string2[128],aname[MAX_PLAYER_NAME],name[MAX_PLAYER_NAME];
- SetPlayerSkin(pID,skinid);
- GetPlayerName(playerid,aname,sizeof(aname));
- GetPlayerName(pID,name,sizeof(name));
- format(string,sizeof(string),"You have set the SkinID of %s to %d",name,skinid);
- format(string2,sizeof(string2),"Admin %s has set your SkinID to %d",aname,skinid);
- SendClientMessage(playerid,COLOR_GREEN,string);
- SendClientMessage(pID,COLOR_GREEN,string2);
- return 1;
- }
- dcmd_sethealth(playerid,params[])
- {
- if(Player[playerid][admin] < 2){
- return SendClientMessage (playerid,COLOR_RED,"You must be a Admin or higher to set Health");
- }
- new pID,life;
- if(sscanf(params,"ud",pID,life)){
- return SendClientMessage(playerid,COLOR_RED,"USAGE: /sethealth [playerid] [float(0-100!)]*");
- }
- if(!IsPlayerConnected(pID)){
- return SendClientMessage(playerid,COLOR_RED,"Nobody is connected with this ID!");
- }
- if(life < 0){
- return SendClientMessage(playerid,COLOR_RED,"INVALID FLOAT!");
- }
- if(life > 100){
- return SendClientMessage(playerid,COLOR_RED,"INVALID FLOAT!");
- }
- if(Player[playerid][admin] < Player[pID][admin]){
- return SendClientMessage(playerid,COLOR_RED,"You can`t use this cmd a high ranked admin");
- }
- new string[128],string2[128],aname[MAX_PLAYER_NAME],name[MAX_PLAYER_NAME];
- SetPlayerHealth(pID,life);
- GetPlayerName(playerid,aname,sizeof(aname));
- GetPlayerName(pID,name,sizeof(name));
- format(string,sizeof(string),"You have set the Health of %s to %d",name,life);
- format(string2,sizeof(string2),"Admin %s has set your Health to %d",aname,life);
- SendClientMessage(playerid,COLOR_GREEN,string);
- SendClientMessage(pID,COLOR_GREEN,string2);
- return 1;
- }
- dcmd_takeweaps(playerid,params[])
- {
- new
- Reason[256],
- pID;
- if(Player[playerid][admin] < 1){
- return SendClientMessage(playerid,COLOR_RED,"You must be a Moderator or higher to take weapons away");
- }
- if(sscanf(params,"us",pID,Reason)){
- return SendClientMessage(playerid,COLOR_RED,"USAGE: /takeweaps [playerid] [reason]");
- }
- if(!IsPlayerConnected(pID)) {
- return SendClientMessage(playerid,COLOR_RED,"Nobody is connected with this ID!");
- }
- if(Player[playerid][admin] < Player[pID][admin]){
- return SendClientMessage(playerid,COLOR_RED,"You can`t use this on a high ranked admin");
- }
- new
- name[MAX_PLAYER_NAME],
- string[256];
- GetPlayerName(pID,name,sizeof(name));
- new
- Aname[MAX_PLAYER_NAME],string2[256];
- GetPlayerName(playerid,Aname,sizeof(Aname));
- format(string,sizeof(string),"Admin %s has taken your weapons with the reason: %s",Aname,Reason);
- format(string2,sizeof(string2),"You have taken the weapons of %s with the reason: %s",name,Reason);
- SendClientMessage(pID,COLOR_GREEN,string);
- ResetPlayerWeapons(pID);
- return 1;
- }
- dcmd_changeweather(playerid,params[])
- {
- if(Player[playerid][admin] < 2){
- return SendClientMessage (playerid,COLOR_RED,"You must be a Admin or higher to change Weather");
- }
- new wetter;
- if(sscanf(params,"d",wetter)){
- return SendClientMessage(playerid,COLOR_RED,"USAGE: /setweather [WeatherID]");
- }
- new string2[128],aname[MAX_PLAYER_NAME];
- SetWeather(wetter);
- GetPlayerName(playerid,aname,sizeof(aname));
- format(string2,sizeof(string2),"Admin %s has set the weather ID to %d",aname,wetter);
- SendClientMessageToAll(COLOR_GREEN,string2);
- return 1;
- }
- dcmd_sethour(playerid,params[])
- {
- if(Player[playerid][admin] < 2){
- return SendClientMessage (playerid,COLOR_RED,"You must be a Admin or higher to change time");
- }
- new hour;
- if(sscanf(params,"d",hour)){
- return SendClientMessage(playerid,COLOR_RED,"USAGE: /sethour [hour]");
- }
- if(hour < 0){
- return SendClientMessage(playerid,COLOR_RED,"INVALID HOUR![0-24]");
- }
- if(hour > 24){
- return SendClientMessage(playerid,COLOR_RED,"INVALID HOUR![0-24]");
- }
- new string2[128],aname[MAX_PLAYER_NAME];
- SetWorldTime(hour);
- GetPlayerName(playerid,aname,sizeof(aname));
- format(string2,sizeof(string2),"Admin %s has set the time to %d",aname,hour);
- SendClientMessageToAll(COLOR_GREEN,string2);
- return 1;
- }
- dcmd_veh(playerid,params[])
- {
- if(Player[playerid][admin] < 3){
- return SendClientMessage (playerid,COLOR_RED,"You must be a SuperAdmin or higher to spawn cars");
- }
- new veh,color1,color2;
- if(sscanf(params,"ddd",veh,color1,color2)){
- return SendClientMessage(playerid,COLOR_RED,"USAGE: /veh [vehicleID] [color1] [color2]");
- }
- if(veh < 400){
- return SendClientMessage(playerid,COLOR_RED,"INVALID vehID![400-611]");
- }
- if(veh > 611){
- return SendClientMessage(playerid,COLOR_RED,"INVALID vehID![400-611]");
- }
- if(color1 < 0){
- return SendClientMessage(playerid,COLOR_RED,"INVALID color1ID![0-126]");
- }
- if(color1 > 126){
- return SendClientMessage(playerid,COLOR_RED,"INVALID color1ID![0-126]");
- }
- if(color2 < 0){
- return SendClientMessage(playerid,COLOR_RED,"INVALID color2ID![0-126]");
- }
- if(color2 > 126){
- return SendClientMessage(playerid,COLOR_RED,"INVALID color2ID![0-126]");
- }
- new Float:x , Float:y , Float: z;
- GetPlayerPos(playerid,x,y,z);
- CreateVehicle(veh, x, y, z, 0, color1, color2, 123456789);
- return 1;
- }
- dcmd_seecash(playerid,params[])
- {
- if(Player[playerid][admin] < 1){
- return SendClientMessage(playerid,COLOR_RED,"You must be a Moderator or higher for this CMD");
- }
- new pID;
- if(sscanf(params,"u",pID)){
- return SendClientMessage(playerid,COLOR_RED,"USAGE: /seecash [playerid]");
- }
- if(!IsPlayerConnected(pID)) {
- return SendClientMessage(playerid,COLOR_RED,"Nobody is connected with this ID!");
- }
- if(Player[playerid][admin] < Player[pID][admin]){
- return SendClientMessage(playerid,COLOR_RED,"You can`t use this cmd on a high ranked admin");
- }
- new
- name[MAX_PLAYER_NAME],
- string2[256];
- GetPlayerName(pID,name,sizeof(name));
- format(string2, sizeof(string2), "[Cash of %s] : %d $",name,GetPlayerMoney(pID));
- SendClientMessage(playerid,COLOR_GREEN,string2);
- return 1;
- }
- dcmd_setcash(playerid,params[])
- {
- if(Player[playerid][admin] < 3){
- return SendClientMessage (playerid,COLOR_RED,"You must be a SuperAdmin or a ServerOwner to set money");
- }
- new pID,cash;
- if(sscanf(params,"ud",pID,cash)){
- return SendClientMessage(playerid,COLOR_RED,"USAGE: /setcash [playerid] [amount]");
- }
- if(!IsPlayerConnected(pID)){
- return SendClientMessage(playerid,COLOR_RED,"Nobody is connected with this ID!");
- }
- if(Player[playerid][admin] < Player[pID][admin]){
- return SendClientMessage(playerid,COLOR_RED,"You can`t use this cmd on a high ranked admin");
- }
- new string[128],string2[128],aname[MAX_PLAYER_NAME],name[MAX_PLAYER_NAME];
- ResetPlayerMoney(pID);
- GivePlayerMoney(pID,cash);
- GetPlayerName(playerid,aname,sizeof(aname));
- GetPlayerName(pID,name,sizeof(name));
- format(string,sizeof(string),"You have set the money of %s to %d $",name,cash);
- format(string2,sizeof(string2),"Admin %s has set your money to %d $",aname,cash);
- SendClientMessage(playerid,COLOR_GREEN,string);
- SendClientMessage(pID,COLOR_GREEN,string2);
- return 1;
- }
- dcmd_setarm(playerid,params[])
- {
- if(Player[playerid][admin] < 2){
- return SendClientMessage (playerid,COLOR_RED,"You must be a Admin or higher to set Armour");
- }
- new pID,arm;
- if(sscanf(params,"ud",pID,arm)){
- return SendClientMessage(playerid,COLOR_RED,"USAGE: /setarm [playerid] [float(0-100!)]*");
- }
- if(!IsPlayerConnected(pID)){
- return SendClientMessage(playerid,COLOR_RED,"Nobody is connected with this ID!");
- }
- if(arm < 0){
- return SendClientMessage(playerid,COLOR_RED,"INVALID FLOAT!");
- }
- if(arm > 100){
- return SendClientMessage(playerid,COLOR_RED,"INVALID FLOAT!");
- }
- if(Player[playerid][admin] < Player[pID][admin]){
- return SendClientMessage(playerid,COLOR_RED,"You can`t use this cmd a high ranked admin");
- }
- new string[128],string2[128],aname[MAX_PLAYER_NAME],name[MAX_PLAYER_NAME];
- SetPlayerArmour(pID,arm);
- GetPlayerName(playerid,aname,sizeof(aname));
- GetPlayerName(pID,name,sizeof(name));
- format(string,sizeof(string),"You have set the Armour of %s to %d",name,arm);
- format(string2,sizeof(string2),"Admin %s has set your Armour to %d",aname,arm);
- SendClientMessage(playerid,COLOR_GREEN,string);
- SendClientMessage(pID,COLOR_GREEN,string2);
- return 1;
- }
- //====================================================================================================================
- stock SendAdminMessage(farbe,msg[])
- {
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(Player[i][admin] >= 1)
- {
- SendClientMessage(i,farbe,msg);
- }
- }
- }
- public StatsTimer()
- {
- for(new i=0;i<MAX_PLAYERS;i++)
- {
- if (IsPlayerConnected(i))
- {
- new str2[128];
- format(str2, sizeof(str2), "Kills:%d Deaths:%d Ratio:%0.2f Score:%d",Player[i][Kills],Player[i][Deaths],Float:Player[i][Kills]/Float:Player[i][Deaths],GetPlayerScore(i));
- TextDrawSetString(StatsTextdraw[i],str2);
- TextDrawShowForPlayer(i,StatsTextdraw[i]);
- }
- }
- return 1;
- }
- //======================================================================================================================
- //==================================================SCANF CODE ====================================================
- 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;
- }
- //================================================= SCANF CODE END =================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement