Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <ZCMD>
- #include <sscanf2>
- #include <dini>
- #include <dudb>
- #include <utils>
- #pragma unused IsNumeric
- #pragma unused ReturnUser
- #define MOD_IME eSport
- #define red 0xAA3333AA
- main()
- {
- print("e-Sport.hr RolePlay 1.0 je ucitan!");
- }
- forward ProvjeriVrijeme(playerid);
- forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);
- // Admin leveli
- enum pData
- {
- pAdminLevel
- };
- // kraj admin leveli
- // Login/reg i sistem spremanja
- #pragma unused ret_memcpy
- #pragma unused strtok
- #define COLOR_GREY 0xAFAFAFAA
- #define COLOR_GREEN 0x33AA33AA
- #define COLOR_ORANGE 0xFF9900AA
- #define COLOR_RED 0xAA3333AA
- #define COLOR_YELLOW 0xFFFF00AA
- enum pInfo
- {
- pAdminLevel,
- pCash,
- pLevel,
- pTimeOnline,
- pMute,
- }
- new levels,Nam[MAX_PLAYER_NAME],pname[MAX_PLAYER_NAME],str[128],ID;
- new PlayerData[MAX_PLAYERS][pData];
- new PlayerInfo[MAX_PLAYERS][pInfo];
- new gPlayerLogged[MAX_PLAYERS];
- new VrijemeOnline;
- #define SERVER_USER_FILE "Korisnici/%s.ini"
- public OnPlayerConnect(playerid)
- {
- gPlayerLogged[playerid] = 0;
- new name[MAX_PLAYER_NAME], file[256];
- GetPlayerName(playerid, name, sizeof(name));
- format(file, sizeof(file), SERVER_USER_FILE, name);
- if (!dini_Exists(file))
- {
- ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Hi your not registered", "Welcome, your not registered mate, input your registration pw below", "Register", "Leave");
- }
- if(fexist(file))
- {
- ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi your registered", "Fucken awesome mate, your registered :D. Inpute your pw below", "Login", "Leave");
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new name[MAX_PLAYER_NAME], file[256];
- GetPlayerName(playerid, name, sizeof(name));
- format(file, sizeof(file), SERVER_USER_FILE, name);
- if(gPlayerLogged[playerid] == 1)
- {
- dini_IntSet(file, "Level", PlayerInfo[playerid][pLevel]);
- dini_IntSet(file, "Money", PlayerInfo[playerid][pCash]);
- dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel]);
- dini_IntSet(file, "Mute",PlayerInfo[playerid][pMute]);
- dini_IntSet(file, "VrijemeOnline",PlayerInfo[playerid][pTimeOnline]);
- }
- gPlayerLogged[playerid] = 0;
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if (dialogid == 1)
- {
- new name[MAX_PLAYER_NAME], file[256], string[128];
- GetPlayerName(playerid, name, sizeof(name));
- format(file, sizeof(file), SERVER_USER_FILE, name);
- if(!response) return Kick(playerid);
- if (!strlen(inputtext)) return
- ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Hi your not registered", "Welcome, your not registered mate, input your registration pw below", "Register", "Leave");
- dini_Create(file);
- dini_IntSet(file, "Password", udb_hash(inputtext));
- dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel] = 0);
- dini_IntSet(file, "Money",PlayerInfo[playerid][pCash] = 0);
- dini_IntSet(file, "Level",PlayerInfo[playerid][pLevel] = 1);
- dini_IntSet(file, "Mute",PlayerInfo[playerid][pMute] = 0);
- dini_IntSet(file, "VrijemeOnline",PlayerInfo[playerid][pTimeOnline] = 0);
- format(string, 128, "[SYSTEM]: You succesfully registered the nickname %s with password %s, you have been auto logged in.", name, inputtext);
- SendClientMessage(playerid, COLOR_YELLOW, string);
- gPlayerLogged[playerid] = 1;
- }
- if (dialogid == 2)
- {
- new name[MAX_PLAYER_NAME], file[256];
- new Levscore;
- GetPlayerName(playerid, name, sizeof(name));
- format(file, sizeof(file), SERVER_USER_FILE, name);
- if(!response) return Kick(playerid);
- if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi your registered", "Fucken awesome mate, your registered :D. Inpute your pw below", "Login", "Leave");
- new tmp;
- tmp = dini_Int(file, "Password");
- if(udb_hash(inputtext) != tmp) {
- SendClientMessage(playerid, COLOR_RED, "Wrong PW sir.");
- ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi your registered", "Fucken awesome mate, your registered :D. Inpute your pw below", "Login", "Leave");
- }
- else
- {
- gPlayerLogged[playerid] = 1;
- PlayerInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel");
- PlayerInfo[playerid][pMute] = dini_Int(file, "Mute");
- PlayerData[ID][pAdminLevel] = dini_Int(file, "AdminLevel");
- PlayerInfo[playerid][pLevel] = dini_Int(file, "Level");
- Levscore = PlayerInfo[playerid][pLevel];
- SetPlayerScore(playerid, Levscore);
- PlayerInfo[playerid][pTimeOnline] = dini_Int(file, "VrijemeOnline");
- GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid));
- SendClientMessage(playerid,COLOR_RED, "[SYSTEM]: Successfully logged in!");
- }
- }
- return 1;
- }
- // kraj Login/reg i sistem spremanja
- // Admin komande
- CMD:postaviadmina(playerid, params[])
- {
- if(!IsPlayerAdmin(playerid))return 0; //Ova komanda radi samo sa rconom
- if(sscanf(params,"ui",ID,levels)) return SendClientMessage(playerid,0xFF9900AA, "Koristenje: /postaviadmina [ID/dio imena] [Level 1-4]");// Pokazat ce ovo ako ne koristi komandu pravilno
- if(levels > 4) return SendClientMessage(playerid,0xFF0000FF,"Greska: Moguci su leveli 1-4.");// Dostupni leveli
- if(!IsPlayerConnected(ID))return SendClientMessage(playerid,0xFF0000FF,"Greska: ID/dio imena koji ste upisali nije ispravan.");//Detektira ako je ID/dioimena online
- if(PlayerData[ID][pAdminLevel] == levels) return SendClientMessage(playerid,0xFF0000FF, "Greska: Taj korisnik vec ima taj admin level.");// Detektira ako je osoba vec taj level
- GetPlayerName(playerid,Nam, MAX_PLAYER_NAME);// Dobiva ime iz id
- GetPlayerName(ID,pname,MAX_PLAYER_NAME);// Dobiva ime druge osobe
- if(levels == 0)
- {
- format(str, sizeof(str),"%s ti je postavio Admin Level %d.",Nam,levels);
- SendClientMessage(ID,0xFF9900AA,str);
- format(str, sizeof(str),"Postavio si %s Admin Level %d.",pname,levels);
- SendClientMessage(playerid,0xFF9900AA,str);
- PlayerData[ID][pAdminLevel] = levels;//ovo postavlja igracev level
- PlayerInfo[playerid][pAdminLevel] = levels;
- return 1;
- }
- format(str, sizeof(str),"%s ti je postavio Admin Level %d.",Nam,levels);
- SendClientMessage(ID,0xFF9900AA,str);
- format(str, sizeof(str),"Postavio si %s Admin Level %d.",pname,levels);
- SendClientMessage(playerid,0xFF9900AA,str);
- PlayerData[ID][pAdminLevel] = levels;
- PlayerInfo[playerid][pAdminLevel] = levels;
- return 1;
- }
- CMD:mute(playerid,params[]) {
- new
- id,
- name1[30],
- name2[30],
- reason[512],
- reason2[512],
- text[512];
- if(sscanf(params,"us",id, reason))
- return SendClientMessage(playerid, 0xFF9900AA,"Koristenje: /mute [ID/dio imena] [Razlog]");
- if(PlayerInfo[playerid][pAdminLevel] >= 2) {
- if(IsPlayerConnected(id)) {
- if(PlayerInfo[id][pAdminLevel] <= PlayerInfo[playerid][pAdminLevel]) {
- if(PlayerInfo[playerid][pMute] == 0) {
- GetPlayerName(playerid,name1,sizeof(name1));
- GetPlayerName(id,name2,sizeof(name2));
- format(text,sizeof(text),"{00DDFF}Administrator {FFEA00}%s{00DDFF} je oduzeo pravo govora igracu {FFEA00}%s{00DDFF}.",name1,name2);
- format(reason2,sizeof(reason2),"{00DDFF}[Razlog: {FFEA00}%s{00DDFF}]", reason);
- SendClientMessageToAll(0xFFEA00,text);
- SendClientMessageToAll(0xFFEA00,reason2);
- PlayerInfo[id][pMute] = 1;
- new command[30];
- format(command,sizeof(command),"unmute(%i)",id);
- } else {
- return SendClientMessage(playerid, 0xFF0000FF,"Greska: Igracu je vec oduzeto pravo govora.");
- }
- } else {
- return SendClientMessage(playerid, 0xFF0000FF,"Greska: Nemozete oduzeti pravo govora adminu veceg levela.");
- }
- } else {
- return SendClientMessage(playerid,0xFF0000FF,"Greska: ID/dio imena koji ste upisali nije ispravan.");
- }
- } else {
- return SendClientMessage(playerid, 0xFF0000FF,"Greska: Ovu komandu mogu koristiti samo admini level 2 ili vise.");
- }
- return 1;
- }
- CMD:unmute(playerid,params[]) {
- new
- id,
- name1[30],
- name2[30],
- text[128];
- if(sscanf(params,"u",id))
- return SendClientMessage(playerid,0xFF9900AA,"Koristenje: /unmute [ID/dio imena]");
- if(PlayerInfo[playerid][pAdminLevel] >= 2) {
- if(IsPlayerConnected(id)) {
- if(PlayerInfo[id][pAdminLevel] <= PlayerInfo[playerid][pAdminLevel]) {
- if(PlayerInfo[playerid][pMute] == 1) {
- GetPlayerName(playerid,name1,sizeof(name1));
- GetPlayerName(id,name2,sizeof(name2));
- format(text,sizeof(text),"{00DDFF}Administrator {FFEA00}%s{00DDFF} je vratio pravo govora igracu {FFEA00}%s{00DDFF}.",name1,name2);
- SendClientMessageToAll(0xFFEA00,text);
- PlayerInfo[id][pMute] = 0;
- } else {
- return SendClientMessage(playerid,0xFF0000FF,"Greska: Igrac vec ima pravo govora.");
- }
- } else {
- return SendClientMessage(playerid,0xFF0000FF,"Greska: Nemozete vratiti pravo govora adminu veceg levela.");
- }
- } else {
- return SendClientMessage(playerid,0xFF0000FF,"Greska: ID/dio imena koji ste upisali nije ispravan.");
- }
- } else {
- return SendClientMessage(playerid,0xFF0000FF,"Greska: Ovu komandu mogu koristiti samo admini level 2 ili vise.");
- }
- return 1;
- }
- //unmute timer:
- forward unmute(id);
- public unmute(id) {
- PlayerInfo[id][pMute] = 0;
- SendClientMessage(id,COLOR_GREEN,"Your mute time is over. You can talk again :]");
- }
- // kraj Admin komande
- // igrac komande
- // kraj igrac komande
- public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
- {
- if(IsPlayerConnected(playerid))
- {
- new Float:posx, Float:posy, Float:posz;
- new Float:oldposx, Float:oldposy, Float:oldposz;
- new Float:tempposx, Float:tempposy, Float:tempposz;
- GetPlayerPos(playerid, oldposx, oldposy, oldposz);
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i) && (GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i)))
- {
- GetPlayerPos(i, posx, posy, posz);
- tempposx = (oldposx -posx);
- tempposy = (oldposy -posy);
- tempposz = (oldposz -posz);
- if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
- {
- SendClientMessage(i, col1, string);
- }
- else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
- {
- SendClientMessage(i, col2, string);
- }
- else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
- {
- SendClientMessage(i, col3, string);
- }
- else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
- {
- SendClientMessage(i, col4, string);
- }
- else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
- {
- SendClientMessage(i, col5, string);
- }
- }
- else
- {
- SendClientMessage(i, col1, string);
- }
- }
- }
- return 1;
- }
- #define COLOR_CHAT1 0xFFFFFFFF
- #define COLOR_CHAT2 0xC8C8C8C8
- #define COLOR_CHAT3 0xAAAAAAAA
- #define COLOR_CHAT4 0x8C8C8C8C
- #define COLOR_CHAT5 0x6E6E6E6E
- #define COLOR_WHITE 0xFFFFFFFF
- public OnPlayerText(playerid, text[])
- {
- new string [128];
- new sendername[MAX_PLAYER_NAME];
- GetPlayerName(playerid, sendername, sizeof(sendername));
- if(PlayerInfo[playerid][pMute] == 1)
- {
- SendClientMessage(playerid, 0xFF0000FF, "Greska: Ne mozete pricati, oduzeto vam je pravo govora.");
- return 0;
- }
- if(PlayerInfo[playerid][pMute] == 0)
- {
- format(string, sizeof(string), "%s: %s ", sendername, text);
- ProxDetector(25.0, playerid, string,COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
- return 0;
- }
- return 0;
- }
- public OnGameModeInit()
- {
- VrijemeOnline = SetTimer("ProvjeriVrijeme",60000,1);
- return 1;
- }
- public OnGameModeExit()
- {
- KillTimer(VrijemeOnline);
- return 1;
- }
- public ProvjeriVrijeme(playerid)
- {
- if(IsPlayerConnected(ID)) {
- PlayerInfo[playerid][pTimeOnline]++;
- }
- return 1;
- }
- forward AddLevel2(playerid);
- public AddLevel2(playerid)
- {
- if(playerid, PlayerInfo[playerid][pTimeOnline] == 300) {
- PlayerInfo[playerid][pLevel]+1;
- return SendClientMessage(playerid,0xFF0000FF,"Info: Congratz! Now you are level 2.");
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement