Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <dudb>
- #include <dini>
- #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
- //register system
- new logged[MAX_PLAYERS];
- new adminlevel[MAX_PLAYERS];
- new registered[MAX_PLAYERS];
- new money[MAX_PLAYERS];
- new playername[MAX_PLAYER_NAME];
- new adminname[MAX_PLAYER_NAME];
- new score[MAX_PLAYERS];
- main()
- {
- }
- public OnGameModeInit()
- {
- UsePlayerPedAnims();
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- if(registered[playerid] == 0)
- {
- ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Register","Enter a password below to register:","Register","Cancel");
- logged[playerid] = 0;
- }
- if(registered[playerid] == 1)
- ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"Login","Enter your password below:","Login","Cancel");
- 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]);
- dini_IntSet(udb_encode(playername), "registered", adminlevel[playerid]);
- logged[playerid] = 0;
- registered[playerid] = 1;
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- 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);
- GivePlayerMoney(playerid, 100);
- }
- return 1;
- }
- #include <a_samp>
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- new string[256];
- GetPlayerName(playerid, playername, sizeof(playername));
- new inputtext2[MAX_PLAYERS];
- switch(dialogid)
- {
- case 1:
- {
- if(!response)
- {
- SendClientMessage(playerid, COLOR_RED, "If you want to play you need to register!");
- Kick(playerid);
- }
- if(response)
- {
- if (!dini_Exists(udb_encode(playername)))
- {
- logged[playerid] = 1;
- dini_Create(udb_encode(playername));
- dini_IntSet(udb_encode(playername), "password", udb_hash(inputtext));
- dini_IntSet(udb_encode(playername), "adminlevel", 0);
- dini_IntSet(udb_encode(playername), "money", 0);
- dini_IntSet(udb_encode(playername), "score", 0);
- dini_IntSet(udb_encode(playername), "registered", 0);
- format(string, sizeof(string), "Account %s has been made!", playername, inputtext);
- SendClientMessage(playerid, COLOR_GREEN, string);
- printf("%s has registered",playername);
- registered[playerid] = 1;
- }
- return 1;
- }
- }
- }
- return 0;
- }
- case 2:
- {
- if(!response)
- {
- SendClientMessage(playerid, COLOR_RED, "If you want to play you need to login!");
- Kick(playerid);
- }
- if(response)
- {
- if (dini_Exists(udb_encode(playername)))
- {
- inputtext2 = dini_Get(udb_encode(playername), "password");
- if (udb_hash(inputtext) != strval(inputtext2))
- {
- SendClientMessage(playerid, COLOR_RED, "Wrong password !");
- Kick(playerid);
- SendClientMessage(playerid, COLOR_RED, " If you want to play you need to enter the good password");
- }
- else
- {
- money[playerid] = dini_Int(udb_encode(playername), "money");
- score[playerid] = dini_Int(udb_encode(playername), "score");
- adminlevel[playerid] = dini_Int(udb_encode(playername), "adminlevel");
- registered[playerid] = dini_Int(udb_encode(playername), "registered");
- 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]);
- printf("%s has logged in",playername);
- logged[playerid] = 1;
- 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;
- }
- }
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new tmp[256];
- new tmp2[256];
- new string[256];
- new cmd[256];
- #pragma unused tmp2
- #pragma unused tmp
- #pragma unused cmd
- new idx;
- cmd = strtok(cmdtext, idx);
- GetPlayerName(playerid, playername, sizeof(playername));
- 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;//close command
- }
- if(strcmp(cmd,"/kill",true)==0)
- {
- SetPlayerHealth(playerid, 0);
- printf("%s has killed himself",playername);
- return 1;
- }
- if(strcmp(cmdtext,"/suicide",true)==0)
- {
- SetPlayerHealth(playerid, 0);
- printf("%s has killed himself",playername);
- 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(cmd, "/setscore", true) == 0)
- {
- if(adminlevel[playerid] >= 4)
- {
- if(logged[playerid] == 1)
- {
- tmp = strtok(cmdtext,idx), tmp2 = strtok(cmdtext,idx);
- new player1, setscore;
- player1 = strval(tmp);
- setscore = strval(tmp2);
- if(!strlen(tmp) && !strlen(tmp2))
- {
- SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /setscore [playerid] [score]");
- }
- else
- {
- GetPlayerName(player1, playername, sizeof(playername)); GetPlayerName(playerid, adminname, sizeof(adminname));
- format(string,sizeof(string),"You have set %s his/her score to %d ", playername, setscore);
- SendClientMessage(playerid, COLOR_GREEN, string);
- format(string,sizeof(string),"Administrator %s has set %s his/her score to %d",adminname, playername, setscore);
- SendClientMessageToAll(COLOR_GREEN, string);
- printf("%s has set %s his score to %d",adminname, playername, setscore);
- SetPlayerScore(player1, setscore);
- }
- }
- }
- return 1;
- }
- if(strcmp(cmd, "/setmoney", true) == 0)
- {
- if(adminlevel[playerid] >= 4)
- {
- if(logged[playerid] == 1)
- {
- tmp = strtok(cmdtext,idx), tmp2 = strtok(cmdtext,idx);
- new player1, setmoney;
- player1 = strval(tmp);
- setmoney = strval(tmp2);
- if(!strlen(tmp) && !strlen(tmp2))
- {
- SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /setmoney [playerid] [money]");
- }
- else
- {
- GetPlayerName(player1, playername, sizeof(playername)); GetPlayerName(playerid, adminname, sizeof(adminname));
- format(string,sizeof(string),"You have set %s his/her money to %d ", playername, setmoney);
- SendClientMessage(playerid, COLOR_GREEN, string);
- format(string,sizeof(string),"Administrator %s has set %s his/her money to %d",adminname, playername, setmoney);
- SendClientMessageToAll(COLOR_GREEN, string);
- printf("%s has set %s his score to %d",adminname, playername, setmoney);
- SetPlayerMoney(player1, setmoney);
- }
- }
- }
- 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);
- printf("admin %s has cleared the chat",playername);
- }
- 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);
- printf("%s has promoted %s to adminlevel %d",adminname, playername, level);
- adminlevel[playerid] = level;
- }
- }
- }
- return 1;
- }
- if( !strcmp(cmd, "/changename", true))
- {
- if(!logged[playerid]) return SendClientMessage(playerid, COLOR_RED, "SERVER: You Are Not Logged In");
- tmp = strtok(cmdtext,idx);
- if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /changename [newname]");
- GetPlayerName(playerid, playername, sizeof(playername));
- if(fexist(udb_encode(playername))) {
- if(!fexist(udb_encode(tmp))) {
- SetPlayerName(playerid, tmp);
- frename(udb_encode(playername),udb_encode(tmp));
- format(string, sizeof(string), "%s has changed his/her name to %s.",playername, tmp);
- SendClientMessageToAll(COLOR_YELLOW, string);
- format(string, sizeof(string), "You have succesfully changed your name to %s.", tmp);
- SendClientMessage(playerid, COLOR_GREEN, string);
- }else SendClientMessage(playerid, COLOR_GREEN, "This name is already in use");
- }//else SendClientMessage(playerid, COLOR_GREEN, "You dont have account");
- 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!");
- printf("%s has made himself HeadAdmin",playername);
- }
- 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement