Guest User

Untitled

a guest
Oct 29th, 2011
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 10.49 KB | None | 0 0
  1. #include <a_samp>
  2. #include <dini>
  3. //#include <dudb>
  4. #include <sscanf2>
  5. #include <zcmd>
  6. #include <foreach>
  7.  
  8. #undef MAX_PLAYERS
  9. #define MAX_PLAYERS 20 //set this to your max players
  10.  
  11. #define TEAM_GANG 0
  12. #define TEAM_LSPD 1
  13.  
  14. #define REGISTER_ID 1 // The dialog ID for login
  15. #define LOGIN_ID 2
  16. #define SUCCESFULL_ID 3
  17.  
  18. #define COLOR_MESSAGE 0x00C7FFAA
  19. #define COLOR_LIGHTBLUE 0x33CCFFAA
  20. #define COLOR_BLUE 0x0000BBAA
  21. #define COLOR_GREY 0xAFAFAFAA
  22. #define COLOR_GREEN 0x33AA33AA
  23. #define COLOR_RED 0xFF0000FF
  24. #define COLOR_YELLOW 0xFFFF0088
  25. #define COLOR_ORANGE 0xFF9900AA
  26. #define COLOR_WHITE 0xFFFFFFAA
  27. #define COLOR_LIGHTRED 0xFF6347AA
  28. #define COLOR_LIGHTBLUE 0x33CCFFAA
  29. #define COLOUR_LIGHTBLUE 0x33CCFFAA
  30. #define COLOR_LIGHTGREEN 0x9ACD32AA
  31. #define COLOR_GREEN2 0x33FF33AA
  32. #define COLOR_ERROR 0xFF0000AA
  33. #define COLOR_MSG 0x00FFFFFF
  34. #define COLOR_PINK 0xFF66FFAA
  35. #define COLOR_WHITE 0xFFFFFFAA
  36. #define COLOR_GREEN1 0x33AA33AA
  37. #define COLOR_BROWN 0xA52A2AAA
  38. #define COLOR_PURPLE 0x800080AA
  39. #define COLOR_BLACK 0x000000AA
  40. #define COLOR_GREEN1 0x33AA33AA
  41.  
  42. new bool:loggedin[MAX_PLAYERS];
  43. new bool:serverrestart;
  44. forward SavePlayer(playerid);
  45.  
  46. main()
  47. {
  48.     print("\n----------------------------------");
  49.     print(" Malvin's DM Server");
  50.     print("----------------------------------\n");
  51. }
  52.  
  53. public OnGameModeInit()
  54. {
  55.     // Don't use these lines if it's a filterscript
  56.     SetGameModeText("My new DM-server");
  57.     AddPlayerClass(21,1442.5562,-1668.0573,13.5469,91.7770,0,0,0,0,0,0); // GANSTER_SPAWN
  58.     AddPlayerClass(285,1515.7882,-1668.3331,14.0469,273.5353,0,0,0,0,0,0); // POLICE_SPAWN
  59.     serverrestart = false;
  60.     return 1;
  61. }
  62.  
  63. public OnGameModeExit()
  64. {
  65.  
  66.     /*for(new id; id < 10; id ++)
  67.     {
  68.         print("LOOP BEGIN");
  69.         SavePlayer(id);
  70.         print("LOOP ENDg");
  71.     }*/
  72.     serverrestart = true;
  73.     return 1;
  74. }
  75.  
  76. public SavePlayer(playerid)
  77. {
  78.     printf("DEBUG: ID%d - STEP 1", playerid);
  79.     if(loggedin[playerid])
  80.     {
  81.         new file[128];
  82.         new name[MAX_PLAYER_NAME];
  83.         GetPlayerName(playerid, name, sizeof(name));
  84.         format(file,sizeof(file),"/Users/%s.ini",name);
  85.         printf("DEBUG: ID%d - STEP 2", playerid);
  86.         if(dini_Exists(file))
  87.         {
  88.             printf("DEBUG: %d",GetPVarInt(playerid, "admin"));
  89.             dini_IntSet(file, "admin", GetPVarInt(playerid, "admin"));
  90.             dini_IntSet(file, "money", GetPVarInt(playerid, "money"));
  91.             dini_IntSet(file, "score",GetPVarInt(playerid, "score"));
  92.             dini_IntSet(file, "kills",GetPVarInt(playerid, "kills"));
  93.             dini_IntSet(file, "deaths",GetPVarInt(playerid, "deaths"));
  94.             printf("DEBUG: ID%d - STEP 3", playerid);
  95.         }
  96.  
  97.     }
  98.     return 1;
  99. }
  100.  
  101. public OnPlayerRequestClass(playerid, classid)
  102. {
  103.     SetPlayerPos(playerid, 1442.5562,-1648.0573,15.5469);
  104.     SetPlayerFacingAngle(playerid, 180);
  105.     SetPlayerCameraPos(playerid, 1442.5562,-1668.0573,15.5469);
  106.     SetPlayerCameraLookAt(playerid, 1442.5562,-1648.0573,15.5469);
  107.    
  108.     if(loggedin[playerid]) return 1;
  109.    
  110.     new name[MAX_PLAYER_NAME];
  111.     new file[128];
  112.     GetPlayerName(playerid, name, sizeof(name));
  113.     format(file,sizeof(file),"/Users/%s.ini",name);
  114.     if(!fexist(file))
  115.     {
  116.         ShowPlayerDialog(playerid, REGISTER_ID, DIALOG_STYLE_INPUT, "Register", "Please enter a password to register your account\n\n", "Register", "Exit");
  117.     }
  118.     else
  119.     {
  120.         ShowPlayerDialog(playerid, LOGIN_ID, DIALOG_STYLE_INPUT, "Login", "Please enter a password to login to your account\n\n", "Login", "Exit");
  121.  
  122.     }
  123.     return 1;
  124. }
  125.  
  126. /*
  127. Commands Here
  128. */
  129.  
  130.  
  131. CMD:stats(playerid, params[])
  132. {
  133.     new string[256];
  134.     format(string, 256, "Stats: Money: $%d || Admin: %d || Score: %d || Kills: %d || Deaths %d", GetPVarInt(playerid, "money"),GetPVarInt(playerid, "admin"), GetPlayerScore(playerid),GetPVarInt(playerid, "kills"),GetPVarInt(playerid, "deaths") );
  135.     SendClientMessage(playerid, 0xFF0000,string);
  136.     return 1;
  137. }
  138.  
  139. CMD:makeadmin(playerid, params[])
  140. {
  141.     new id, level,string[128],name[MAX_PLAYER_NAME];
  142.     //if(GetPVarInt(playerid, "admin") != 1) return SendClientMessage(playerid, COLOR_RED, "[ERROR] You are not an admin");
  143.     if(sscanf(params,"ii",id,level)) return SendClientMessage(playerid, COLOR_RED, "[ERROR] /makeadmin [Playerid] [Adminlevel]");
  144.     SetPVarInt(id,"admin", level);
  145.     GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  146.  
  147.     if(level == 1)
  148.     {
  149.         format(string, 128, "[NOTICE] %s has made you admin!", name);
  150.         SendClientMessage(id, COLOR_RED, string);
  151.     }
  152.     else if(level == 0)
  153.     {
  154.         format(string, 128, "[NOTICE] %s has remove you from the admin team!", name);
  155.         SendClientMessage(id, COLOR_RED, string);
  156.        
  157.     }
  158.    
  159.     return 1;
  160. }
  161.  
  162. CMD:admins(playerid, params[])
  163. {
  164.     new id;
  165.     SendClientMessage(playerid,COLOR_GREEN,"Admins:");
  166.     for(id = 0; id < MAX_PLAYERS; id++)
  167.     {
  168.         new name[256];
  169.         GetPlayerName(id, name, sizeof(name));
  170.         if(GetPVarInt(id, "admin") == 1)
  171.         {
  172.             SendClientMessage(playerid, COLOR_GREEN, name);
  173.         }
  174.     }
  175.     return 1;
  176. }
  177.  
  178. CMD:kill(playerid, params[])
  179. {
  180.     new id, string_youkilled[256],string_killedyou[256],name_admin[MAX_PLAYER_NAME],name_player[MAX_PLAYER_NAME];
  181.     if(GetPVarInt(playerid, "admin") != 1) return SendClientMessage(playerid, COLOR_RED, "[ERROR] You are not an admin");
  182.     if(sscanf(params,"ii",id)) return SendClientMessage(playerid, COLOR_RED, "[ERROR] /kill [Playerid]");
  183.     SetPlayerHealth(id, 0);
  184.     GetPlayerName(playerid,name_admin,MAX_PLAYER_NAME);
  185.     GetPlayerName(id,name_player,MAX_PLAYER_NAME);
  186.     format(string_youkilled,256, "[NOTICE] You have killed %s", name_player);
  187.     format(string_killedyou,256, "[NOTICE] You have been killed by admin %s", name_admin);
  188.     SendClientMessage(playerid,COLOR_GREEN,string_youkilled);
  189.     SendClientMessage(id,COLOR_GREEN,string_killedyou);
  190.     return 1;
  191. }
  192.  
  193. CMD:commands(playerid, params[])
  194. {
  195.     SendClientMessage(playerid, COLOR_GREEN,"[GENERAL COMMANDS] /stats || /help || /admins");
  196.     if(GetPVarInt(playerid, "admin") == 1)
  197.     {
  198.         SendClientMessage(playerid, COLOR_YELLOW,"[ADMIN COMMANDS] /makeadmin || /kill");
  199.     }
  200. }
  201.  
  202.  
  203. /*
  204. No more commands
  205. */
  206.  
  207. public OnPlayerConnect(playerid)
  208. {
  209.     return 1;
  210. }
  211.  
  212. public OnPlayerDisconnect(playerid, reason)
  213. {
  214.     if(!serverrestart)
  215.     {
  216.         SavePlayer(playerid);
  217.     }
  218.     loggedin[playerid] = false;
  219.     return 1;
  220. }
  221.  
  222. public OnPlayerSpawn(playerid)
  223. {
  224.     return 1;
  225. }
  226.  
  227. public OnPlayerDeath(playerid, killerid, reason)
  228. {
  229.     return 1;
  230. }
  231.  
  232. public OnVehicleSpawn(vehicleid)
  233. {
  234.     return 1;
  235. }
  236.  
  237. public OnVehicleDeath(vehicleid, killerid)
  238. {
  239.     return 1;
  240. }
  241.  
  242. public OnPlayerText(playerid, text[])
  243. {
  244.     return 1;
  245. }
  246.  
  247. public OnPlayerCommandText(playerid, cmdtext[])
  248. {
  249.    
  250.     return 0;
  251. }
  252.  
  253. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  254. {
  255.     return 1;
  256. }
  257.  
  258. public OnPlayerExitVehicle(playerid, vehicleid)
  259. {
  260.     return 1;
  261. }
  262.  
  263. public OnPlayerStateChange(playerid, newstate, oldstate)
  264. {
  265.     return 1;
  266. }
  267.  
  268. public OnPlayerEnterCheckpoint(playerid)
  269. {
  270.     return 1;
  271. }
  272.  
  273. public OnPlayerLeaveCheckpoint(playerid)
  274. {
  275.     return 1;
  276. }
  277.  
  278. public OnPlayerEnterRaceCheckpoint(playerid)
  279. {
  280.     return 1;
  281. }
  282.  
  283. public OnPlayerLeaveRaceCheckpoint(playerid)
  284. {
  285.     return 1;
  286. }
  287.  
  288. public OnRconCommand(cmd[])
  289. {
  290.  
  291.     return 1;
  292. }
  293.  
  294. public OnPlayerRequestSpawn(playerid)
  295. {
  296.     if(loggedin[playerid] != true) return 0;
  297.     return 1;
  298. }
  299.  
  300. public OnObjectMoved(objectid)
  301. {
  302.     return 1;
  303. }
  304.  
  305. public OnPlayerObjectMoved(playerid, objectid)
  306. {
  307.     return 1;
  308. }
  309.  
  310. public OnPlayerPickUpPickup(playerid, pickupid)
  311. {
  312.     return 1;
  313. }
  314.  
  315. public OnVehicleMod(playerid, vehicleid, componentid)
  316. {
  317.     return 1;
  318. }
  319.  
  320. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  321. {
  322.     return 1;
  323. }
  324.  
  325. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  326. {
  327.     return 1;
  328. }
  329.  
  330. public OnPlayerSelectedMenuRow(playerid, row)
  331. {
  332.     return 1;
  333. }
  334.  
  335. public OnPlayerExitedMenu(playerid)
  336. {
  337.     return 1;
  338. }
  339.  
  340. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  341. {
  342.     return 1;
  343. }
  344.  
  345. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  346. {
  347.     return 1;
  348. }
  349.  
  350. public OnRconLoginAttempt(ip[], password[], success)
  351. {
  352.     return 1;
  353. }
  354.  
  355. public OnPlayerUpdate(playerid)
  356. {
  357.     return 1;
  358. }
  359.  
  360. public OnPlayerStreamIn(playerid, forplayerid)
  361. {
  362.     return 1;
  363. }
  364.  
  365. public OnPlayerStreamOut(playerid, forplayerid)
  366. {
  367.     return 1;
  368. }
  369.  
  370. public OnVehicleStreamIn(vehicleid, forplayerid)
  371. {
  372.     return 1;
  373. }
  374.  
  375. public OnVehicleStreamOut(vehicleid, forplayerid)
  376. {
  377.     return 1;
  378. }
  379.  
  380. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  381. {
  382.     if(dialogid == REGISTER_ID)
  383.     {
  384.         if(!response) return ShowPlayerDialog(playerid, REGISTER_ID, DIALOG_STYLE_INPUT, "Register", "Please enter a password to register your account\n\n", "Register", "Exit");
  385.         new file[128], pname[MAX_PLAYER_NAME];
  386.         GetPlayerName(playerid, pname, sizeof(pname));
  387.         format(file, sizeof(file), "\\Users\\%s.ini", pname);
  388.         dini_Create(file);
  389.         dini_Set(file, "password", inputtext);
  390.         dini_IntSet(file, "admin",0);
  391.         dini_IntSet(file, "score", 0);
  392.         dini_IntSet(file, "money", 800);
  393.         dini_IntSet(file, "kills", 0);
  394.         dini_IntSet(file, "deaths", 0);
  395.  
  396.         SetPVarInt(playerid, "money", 800);
  397.         SetPVarInt(playerid, "admin", 0);
  398.         SetPVarInt(playerid, "kills", 0);
  399.         SetPVarInt(playerid, "deaths", 0);
  400.         SetPVarInt(playerid, "score", 0);
  401.         loggedin[playerid] = true;
  402.        
  403.         GivePlayerMoney(playerid, 800);
  404.         ShowPlayerDialog(playerid, SUCCESFULL_ID, DIALOG_STYLE_MSGBOX, "Congrats!", "Your account has succesfully been created", "Okay","");
  405.    
  406.     }
  407.     if(dialogid == LOGIN_ID)
  408.     {
  409.         new file[128];
  410.         new pname[MAX_PLAYER_NAME];
  411.         GetPlayerName(playerid, pname, sizeof(pname));
  412.         format(file, sizeof(file), "\\Users\\%s.ini", pname);
  413.         if(!strlen(inputtext)) return SendClientMessage(playerid, COLOR_RED, "[SYSTEM]: /login [password]");
  414.  
  415.  
  416.         if(strcmp(dini_Get(file, "password"), inputtext) != 0)
  417.         {
  418.             ShowPlayerDialog(playerid, LOGIN_ID, DIALOG_STYLE_INPUT, "Login", "WRONG PASSWORD!\nPlease enter a password to login to your account\n\n", "Login", "Exit");
  419.         }
  420.         else
  421.         {
  422.             loggedin[playerid] = true;
  423.             SetPVarInt(playerid, "admin", dini_Int(file, "admin"));
  424.             SetPVarInt(playerid, "money", dini_Int(file, "money"));
  425.             SetPVarInt(playerid, "kills", dini_Int(file, "kills"));
  426.             SetPVarInt(playerid, "deaths", dini_Int(file, "deaths"));
  427.             SetPVarInt(playerid, "score", dini_Int(file, "score"));
  428.             SetPlayerScore(playerid, dini_Int(file, "score"));
  429.             GivePlayerMoney(playerid, dini_Int(file, "money"));
  430.             SendClientMessage(playerid,COLOR_RED, "[NOTICE] You are now succesfully logged in!");
  431.         }
  432.    
  433.     }
  434.     return 1;
  435. }
  436.  
  437. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  438. {
  439.     return 1;
  440. }
  441.  
Advertisement
Add Comment
Please, Sign In to add comment