Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma tabsize 0
- #define FILTERSCRIPT
- #include <a_samp>
- #include <dini>
- #define SCM SendClientMessage
- #define PlayerIsAdmin(%1) (PInfo[%1][Adminlevel] > 0 || IsPlayerAdmin(%1))
- #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
- #define GREY 0xAFAFAFAA
- #define GREEN 0x33AA33AA
- #define YELLOW 0xFFFF00AA
- #define WHITE 0xFFFFFFAA
- #define LIGHTBLUE 0x33CCFFAA
- #define ORANGE 0xFF9900AA
- enum gPInfo
- {
- Logged,
- Regged,
- Viplevel,
- Adminlevel,
- level
- };
- new PInfo[MAX_PLAYERS][gPInfo];
- #if defined FILTERSCRIPT
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Game Mode By Eddy");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- #else
- main()
- {
- print("\n----------------------------------");
- print(" Blank Gamemode by your name here");
- print("----------------------------------\n");
- }
- #endif
- public OnGameModeInit()
- {
- // Don't use these lines if it's a filterscript
- SetGameModeText("Blank Script");
- AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- return 1;
- }
- dcmd_setvip(playerid,params[])
- {
- new name[24],pname[24],string[128],viplevel,id;
- if(!PlayerIsAdmin(playerid)) return 0;
- if(sscanf(params,"ud",id,Viplevel)) {
- SCM(playerid,-1,"SYNTAX: /setvip [playerid/name] [level 0-4]");
- SCM(playerid,-1,"SYNTAX: , 1: Rat ,2: Tiger ,3: Lion ,4: SuperWooper");
- } else {
- if(!IsPlayerConnected(id)) return SCM(playerid,-1,"Player not connected.");
- if(viplevel > 4 || viplevel < 0) {
- SCM(playerid,-1,"SYNTAX: /setvip [playerid/name] [level 0-4]");
- SCM(playerid,-1,"SYNTAX: 1: Rat ,2: Tiger ,3: Lion ,4: SuperWooper");
- }
- GetPlayerName(playerid,name,24);
- GetPlayerName(id,pname,24);
- switch(viplevel)
- {
- case 0: format(string,sizeof(string),"%s(%d) is no more a VIP.",pname,id);
- case 1: format(string,sizeof(string),"You have set %s(%d)'s VIP status to: Rat.",pname,id);
- case 2: format(string,sizeof(string),"You have set %s(%d)'s VIP status to: Tiger.",pname,id);
- case 3: format(string,sizeof(string),"You have set %s(%d)'s VIP status to: Lion.",pname,id);
- case 4: format(string,sizeof(string),"You have set %s(%d)'s VIP status to: SuperWooper.",pname,id);
- }
- SendClientMessage(playerid,-1,string);
- switch(Viplevel)
- {
- case 0: format(string,sizeof(string),"%s(%d) has removed your VIP status.",name,playerid);
- case 1: format(string,sizeof(string),"%s(%d) has set your VIP status to: Rat.",name,playerid);
- case 2: format(string,sizeof(string),"%s(%d) has set your VIP status to: Tiger.",name,playerid);
- case 3: format(string,sizeof(string),"%s(%d) has set your VIP status to: Lion.",name,playerid);
- case 4: format(string,sizeof(string),"%s(%d) has set your VIP status to: SuperWooper.",name,playerid);
- }
- SendClientMessage(id,-1,string);
- PInfo[id][Viplevel] = Viplevel;
- }
- return 1;
- }
- //----------------------------------
- dcmd_viplocker(playerid,params[])
- {
- #pragma unused params
- if(PInfo[playerid][Viplevel] == 0) return SendClientMessage(playerid,-1, "lol go get some money to be a vip");
- ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Enjoy your Vip", "Health \nArmour \nMiniGun /n /nMore coming soon", "Okay", "Quit");
- return 1;
- }
- //========================= >>> REGISTER <<< =================================//
- dcmd_register(playerid,params[])
- {
- new file[256],n[MAX_PLAYER_NAME];
- GetPlayerName(playerid,n,MAX_PLAYER_NAME);
- format(file,sizeof(file),"MyAdmin/Users/%s.txt",n);
- if(dini_Exists(file)) return SendClientMessage(playerid,YELLOW,"You are already registered!");
- if(PInfo[playerid][Regged] == 1) return SendClientMessage(playerid,LIGHTBLUE,"You are already registered!");
- if(PInfo[playerid][Logged] == 1) return SendClientMessage(playerid,ORANGE,"You are already registered, and logged in!");
- if(strlen(params))
- {
- if(!dini_Exists(file))
- {
- dini_Create(file);
- dini_Set(file,"Password",params);
- dini_IntSet(file,"Regged",1);
- dini_IntSet(file,"Logged",0);
- dini_IntSet(file,"level",0);
- dini_IntSet(file,"Viplevel",0);
- SendClientMessage(playerid,LIGHTBLUE,"Congratulations, you have just registered, please /login");
- PInfo[playerid][Regged] = 1;
- return 1;
- }
- }
- else
- {
- SendClientMessage(playerid,GREY,"USAGE: /register <Password>");
- return 1;
- }
- return 1;
- }
- //===========================>>> LOGIN <<<======================================
- dcmd_login(playerid,params[])
- {
- new file[256],n[MAX_PLAYER_NAME];
- GetPlayerName(playerid,n,MAX_PLAYER_NAME);
- format(file,sizeof(file),"MyAdmin/Users/%s.txt",n);
- if(!dini_Exists(file)) return SendClientMessage(playerid,YELLOW,"You are not registered! Please /register");
- if(PInfo[playerid][Logged] == 1) return SendClientMessage(playerid,LIGHTBLUE,"You are already logged in!");
- if(PInfo[playerid][Regged] == 0) return SendClientMessage(playerid,ORANGE,"You are not registered! Please /register");
- if(strlen(params))
- {
- new pass[256];
- pass = dini_Get(file,"Password");
- if(dini_Exists(file))
- {
- if(strcmp(params,pass,false) != 0)
- {
- SendClientMessage(playerid,YELLOW,"Wrong Password!");
- }
- else
- {
- dini_IntSet(file,"Logged",1);
- PInfo[playerid][Logged] = 1;
- PInfo[playerid][level] = dini_Int(file,"level");
- PInfo[playerid][Viplevel] = dini_Int(file,"Viplevel");
- SendClientMessage(playerid,YELLOW,"You have now logged in!");
- return 1;
- }
- }
- }
- else
- {
- SendClientMessage(playerid,GREY,"USAGE: /login <Password>");
- SendClientMessage(playerid,GREY,"Then Press Spawn");
- return 1;
- }
- return 1;
- }
- public OnGameModeExit()
- {
- 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)
- {
- PInfo[playerid][Logged] = 0;
- PInfo[playerid][Regged] = 0;
- PInfo[playerid][Viplevel] = 0;
- PInfo[playerid][level] = 0;
- new n[MAX_PLAYER_NAME], file[256];
- GetPlayerName(playerid,n,sizeof(n));
- format(file,sizeof(file),"MyAdmin/Users/%s.txt",n);
- if(dini_Exists(file))
- {
- SendClientMessage(playerid,LIGHTBLUE,"You are registered, Please /login!");
- PInfo[playerid][Regged] = 1;
- PInfo[playerid][Logged] = 0;
- return 1;
- }
- if(!dini_Exists(file))
- {
- SendClientMessage(playerid,LIGHTBLUE,"You are not registered, Please /register!");
- PInfo[playerid][Regged] = 0;
- PInfo[playerid][Logged] = 0;
- return 1;
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new n[MAX_PLAYER_NAME], file[256];
- GetPlayerName(playerid,n,sizeof(n));
- format(file,sizeof(file),"MyAdmin/Users/%s.txt",n);
- PInfo[playerid][Logged] = 0;
- dini_IntSet(file,"Logged",0);
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new cmd[256], idx;
- cmd = strtok(cmdtext, idx);
- dcmd(register,8,cmdtext);
- dcmd(login,5,cmdtext);
- dcmd(setvip,6,cmdtext);
- dcmd(viplocker,9,cmdtext);
- return 0;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(response)
- {
- switch(dialogid)
- {
- case 1:
- {
- switch(listitem)
- {
- case 0:
- {
- SetPlayerHealth(playerid, 100.0);
- }
- case 1:
- {
- SetPlayerArmour(playerid, 100.0);
- }
- case 2:
- {
- GivePlayerWeapon(playerid, 38, 5000);
- }
- }
- }
- }
- }
- 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':
- {
- setarg(paramPos, 0, _:floatstr(string[stringPos]));
- }
- 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;
- }
- //--------------------------------
- strtok(const string[], &index)
- {
- new length = strlen(string);
- while ((index < length) && (string[index] <= ' '))
- {
- index++;
- }
- new offset = index;
- new result[20];
- while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
- {
- result[index - offset] = string[index];
- index++;
- }
- result[index - offset] = EOS;
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement