Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <dudb>
- #define COLOR_GRAD1 0xB4B5B7FF
- #define COLOR_GRAD2 0xBFC0C2FF
- #define COLOR_GRAD3 0xCBCCCEFF
- #define COLOR_GRAD4 0xD8D8D8FF
- #define COLOR_GRAD5 0xE3E3E3FF
- #define COLOR_GRAD6 0xF0F0F0FF
- #define COLOR_LIGHTBLUE 0x33CCFFAA
- #define COLOR_GREY 0xAFAFAFAA
- #define COLOR_PINK 0xFF008096
- #define COLOR_BLUE 0x0000FFFF
- #define COLOR_GREEN 0x00A80096
- #define COLOR_RED 0xFF0000AA
- #define COLOR_ORANGE 0xFF800096
- #define COLOR_CYAN 0xFF808096
- #define COLOR_YELLOW 0xFFFF00AA
- #define COLOR_WHITE 0xFFFFFFAA
- #define COLOR_FADE1 0xE6E6E6E6
- #define COLOR_FADE2 0xC8C8C8C8
- #define COLOR_DARKBLUE 0x0000A096
- #define COLOR_BLACK 0x00000096
- #define COLOR_DARKGOLD 0x80800096
- #define COLOR_FADE3 0xAAAAAAAA
- #define COLOR_FADE4 0x8C8C8C8C
- #define COLOR_FADE5 0x6E6E6E6E
- #define COLOR_PURPLE 0xFF00FF96
- #define COLOR_BROWN 0x80400096
- #define COLOR_DBLUE 0x2641FEAA
- #define COLOR_ALLDEPT 0xFF8282AA
- #define SendError SendClientMessage
- forward CountDown();
- //register system
- new logged[MAX_PLAYERS];
- new adminlevel[MAX_PLAYERS];
- new money[MAX_PLAYERS];
- new playername[MAX_PLAYER_NAME];
- new adminname[MAX_PLAYER_NAME];
- new score[MAX_PLAYERS];
- //race count
- new Count;
- main()
- {
- }
- public OnGameModeInit()
- {
- UsePlayerPedAnims();
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- logged[playerid] = 0;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- GetPlayerName(playerid, playername, sizeof(playername));
- money[playerid] = GetPlayerMoney(playerid);
- score[playerid] = GetPlayerScore(playerid);
- dini_IntSet(udb_encode(playername), "money", money[playerid]);
- dini_IntSet(udb_encode(playername), "score", score[playerid]);
- dini_IntSet(udb_encode(playername), "adminlevel", adminlevel[playerid]);
- logged[playerid] = 0;
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- if(logged[playerid] == 0)
- {
- SendClientMessage(playerid, COLOR_RED, "You are not logged in yet! USAGE: /login [password]!");
- }
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- if(killerid == INVALID_PLAYER_ID) {
- SendDeathMessage(INVALID_PLAYER_ID,playerid,reason);
- } else {
- // Valid kill
- SendDeathMessage(killerid,playerid,reason);
- SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
- }
- return 1;
- }
- public CountDown()
- {
- if (Count > 0)
- {
- new string[10];
- format(string,sizeof(string),"~r~%d",Count);
- GameTextForAll(string, 2000, 3);
- Count--;
- SetTimer("CountDown", 1000, 0);
- }
- else
- {
- GameTextForAll("~g~GO!", 2500, 3);
- Count = 0;
- }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new string[256];
- new cmd[256],tmp[256], tmp2[256];
- new idx;
- cmd = strtok(cmdtext, idx);
- GetPlayerName(playerid, playername, sizeof(playername));
- if(strcmp(cmd, "/register", true) == 0)
- {
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp))
- {
- SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /register (password)");
- }
- else
- {
- if (!dini_Exists(udb_encode(playername)))
- {
- dini_Create(udb_encode(playername));
- dini_IntSet(udb_encode(playername), "password", udb_hash(tmp));
- dini_IntSet(udb_encode(playername), "adminlevel", 0);
- dini_IntSet(udb_encode(playername), "money", 0);
- dini_IntSet(udb_encode(playername), "score", 0);
- format(string, sizeof(string), "Account %s has been made! You can now login with the password: %s.", playername, tmp);
- SendClientMessage(playerid, COLOR_GREEN, string);
- }
- else
- {
- format(string, sizeof(string), "%s is already registered.", playername,tmp);
- SendClientMessage(playerid, COLOR_RED, string);
- }
- }
- return 1;
- }
- if(strcmp(cmd, "/login", true) == 0)
- {
- tmp = strtok(cmdtext, idx);
- if(logged[playerid] == 1)
- {
- SendClientMessage(playerid, COLOR_RED, "You are already logged in!");
- return 1;
- }
- if(!strlen(tmp)){
- SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /login (password)");
- }
- else
- {
- if (dini_Exists(udb_encode(playername)))
- {
- tmp2 = dini_Get(udb_encode(playername), "password");
- if (udb_hash(tmp) != strval(tmp2))
- {
- SendClientMessage(playerid, COLOR_RED, "Wrong password");
- }
- else
- {
- logged[playerid] = 1;
- money[playerid] = dini_Int(udb_encode(playername), "money");
- score[playerid] = dini_Int(udb_encode(playername), "score");
- adminlevel[playerid] = dini_Int(udb_encode(playername), "adminlevel");
- format(string, sizeof(string), "%s, You are now logged in. Your adminlevel is %d, Your money is %d, and your score is %d.", playername, adminlevel[playerid], money[playerid], score[playerid]);
- SendClientMessage(playerid, COLOR_GREEN, string);
- GivePlayerMoney(playerid, money[playerid]);
- SetPlayerScore(playerid, score[playerid]);
- return 1;
- }
- }
- else
- {
- format(string, sizeof(string), "The account %s does not exist yet. Type /register [password] to make an account.", playername);
- SendClientMessage(playerid, COLOR_RED, string);
- return 1;
- }
- }
- }
- if(strcmp(cmd,"/bug",true,4)==0)
- {
- if(strlen(cmdtext) < 6) return SendClientMessage(playerid,COLOR_RED,"Usage: /bug [details]");
- new bug[256];
- new name[30];
- GetPlayerName(playerid,name,30);
- strmid(bug,cmdtext,5,strlen(cmdtext));
- format(string,256,"Bug Report - Author: %s - Details: %s",name,bug);
- SendClientMessage(playerid,COLOR_GREEN,"Your bug report said:");
- SendClientMessage(playerid,COLOR_GREEN,string);
- SendClientMessage(playerid,COLOR_GREEN,"Thank you for submitting the bug report and making this gamemode better.");
- printf("%s",string);
- new File:bugs;
- bugs = fopen("bugs.txt",io_append);
- format(string,256,"%s\r\n",string);
- fwrite(bugs,string);
- fclose(bugs);
- return 1;
- }
- if(strcmp(cmdtext,"/kill",true)==0)
- {
- SetPlayerHealth(playerid, 0);
- return 1;
- }
- if(strcmp(cmdtext,"/suicide",true)==0)
- {
- SetPlayerHealth(playerid, 0);
- return 1;
- }
- if(strcmp(cmdtext,"/clearchat",true)==0)
- {
- SendClientMessage(playerid,COLOR_GREY," ");
- SendClientMessage(playerid,COLOR_GREY," ");
- SendClientMessage(playerid,COLOR_GREY," ");
- SendClientMessage(playerid,COLOR_GREY," ");
- SendClientMessage(playerid,COLOR_GREY," ");
- SendClientMessage(playerid,COLOR_GREY," ");
- SendClientMessage(playerid,COLOR_GREY," ");
- SendClientMessage(playerid,COLOR_GREY," ");
- SendClientMessage(playerid,COLOR_GREY," ");
- SendClientMessage(playerid,COLOR_GREY," ");
- return 1;
- }
- if (strcmp(cmd, "/pbanana", true) == 0)
- {
- if(IsPlayerConnected(playerid))
- {
- GivePlayerWeapon(playerid, 10, 1);
- SendClientMessage(playerid, 0xB013ECFF, "You now have a purple banana! Yummy!");
- return 1;
- }
- }
- if(strcmp(cmdtext,"/aclearchat",true)==0)
- {
- if(adminlevel[playerid] == 7)
- {
- GetPlayerName(playerid, playername, sizeof(playername));
- SendClientMessageToAll(COLOR_GREY," ");
- SendClientMessageToAll(COLOR_GREY," ");
- SendClientMessageToAll(COLOR_GREY," ");
- SendClientMessageToAll(COLOR_GREY," ");
- SendClientMessageToAll(COLOR_GREY," ");
- SendClientMessageToAll(COLOR_GREY," ");
- SendClientMessageToAll(COLOR_GREY," ");
- SendClientMessageToAll(COLOR_GREY," ");
- SendClientMessageToAll(COLOR_GREY," ");
- SendClientMessageToAll(COLOR_GREY," ");
- format(string,sizeof(string),"Admin %s has cleared the chat", playername);
- SendClientMessageToAll(COLOR_GREEN, string);
- }
- return 1;
- }
- if(strcmp(cmd, "/makeadmin", true) == 0)
- {
- if(adminlevel[playerid] == 7)
- {
- if(logged[playerid] == 1)
- {
- tmp = strtok(cmdtext,idx), tmp2 = strtok(cmdtext,idx);
- new player1, level;
- player1 = strval(tmp);
- level = strval(tmp2);
- if(!strlen(tmp) && !strlen(tmp2))
- {
- SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /makeadmin [playerid] [level]");
- }
- else
- {
- GetPlayerName(player1, playername, sizeof(playername)); GetPlayerName(playerid, adminname, sizeof(adminname));
- format(string,sizeof(string),"You have promoted %s to adminlevel %d ", playername, level);
- SendClientMessage(playerid, COLOR_GREEN, string);
- format(string,sizeof(string),"Administrator %s has promoted %s to adminlevel %d",adminname, playername, level);
- SendClientMessageToAll(COLOR_GREEN, string);
- adminlevel[playerid] = level;
- }
- }
- }
- return 1;
- }
- if(strcmp(cmdtext,"/count",true) == 0)
- {
- if(Count > 0) return SendClientMessage(playerid,0xFFFFFFFAA,"Already countdown in progress");
- Count = 5;
- CountDown();
- return 1;
- }
- if ( !strcmp ( cmd, "/changename", true ) )
- {
- tmp = strtok(cmdtext, idx);
- new string3[256];
- if(logged[playerid] == 0)
- {
- SendClientMessage(playerid, COLOR_RED, "SERVER: You Are Not Logged In");
- return 1;
- }
- if(!strlen(tmp))
- {
- SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /changenick [newname]");
- return 1;
- }
- if (!dini_Exists(playername))
- {
- format(string3, sizeof(string3),"%s has changed he's name to %s.", playername,tmp);
- SendClientMessageToAll(COLOR_YELLOW, string3);
- dini_Remove(udb_encode(playername));
- SetPlayerName(playerid, tmp);
- GetPlayerName(playerid, playername, sizeof(playername));
- dini_Create(udb_encode(playername));
- }
- else
- {
- SendClientMessage(playerid, COLOR_RED, "This name is already in use");
- return 1;
- }
- if( !strcmp ( cmd, "/changepass", true ) )
- {
- if(logged[playerid] == 0)
- {
- SendClientMessage(playerid, COLOR_RED, "SERVER: You Are Not Logged In");
- return 1;
- }
- tmp = strtok(cmdtext,idx);
- if(!strlen(tmp))
- {
- SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /changepass [password]");
- return 1;
- }
- if(logged[playerid] == 1)
- {
- dini_IntSet(udb_encode(playername), "password", udb_hash(tmp));
- format(string, sizeof(string), "You have successfully changed your password to %s. Dont forget it!", tmp);
- SendClientMessage(playerid, COLOR_GREEN, string);
- }
- return 1;
- }
- if ( !strcmp ( cmdtext, "/mystats", true ) )
- {
- SendClientMessage ( playerid, COLOR_LIGHTBLUE, "====*[Playerstats]*====" );
- format(string, sizeof(string), "Score: %d", score[playerid]);
- SendClientMessage(playerid, COLOR_GREEN, string);
- format(string, sizeof(string), "Money: %d dollar", money[playerid]);
- SendClientMessage(playerid, COLOR_GREEN, string);
- format(string, sizeof(string), "Adminlevel: %d", adminlevel[playerid]);
- SendClientMessage(playerid, COLOR_GREEN, string);
- return 1;
- }
- if(strcmp(cmd, "/makemeadmin", true) == 0)
- {
- if(IsPlayerAdmin(playerid))
- {
- if(logged[playerid] == 1)
- {
- if(adminlevel[playerid] >= 0)
- {
- adminlevel[playerid] = 7;
- SendClientMessage(playerid, COLOR_GREEN, "You are now HeadAdmin, Congratulations!");
- }
- else
- {
- SendClientMessage(playerid, COLOR_RED, "You are already a Headadmin!");
- }
- }
- else
- {
- SendClientMessage(playerid, COLOR_RED, "You are not logged in yet, USAGE: /login password");
- }
- }
- else
- {
- SendClientMessage(playerid, COLOR_RED, "You are not a rcon admin!");
- }
- return 1;
- }
- return 0;
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement