Advertisement
Guest User

[SA-MP] Errors in WWAdmin

a guest
May 16th, 2012
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 26.18 KB | None | 0 0
  1. //Credits to Y_Less, Dracoblue and Kush.
  2.  
  3. #include <a_samp>
  4. #include <YSI\y_ini>
  5. #include <sscanf2>
  6. #include <pvehicle>
  7. #include <GetVehicleName>
  8.  
  9. #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
  10.  
  11. #define DIALOG_REGISTER 1
  12. #define DIALOG_LOGIN 2
  13. #define DIALOG_SUCCESS_1 3
  14. #define DIALOG_SUCCESS_2 4
  15. #define DIALOG_ADVEHICLES 5
  16.  
  17. #define PATH "WWAdmin/Users/%s.ini"
  18.  
  19. #define COL_WHITE "{FFFFFF}"
  20. #define COL_RED "{F81414}"
  21. #define COL_GREEN "{00FF22}"
  22. #define COL_LIGHTBLUE "{00CED1}"
  23. #define COLOR_RED 0xFF0000FF
  24. #define COLOR_GREEN 0x00FF00FF
  25. #define COLOR_YELLOW 0xFFFF00FF
  26. #define COLOR_BLACK 0x000000FF
  27. #define COLOR_AQUA 0x00FFFFFF
  28. #define COLOR_LIGHTPURPLE 0xFF00FFFF
  29. #define COLOR_BLUE 0x0000FFFF
  30. #define COLOR_GREY 0x0000005E
  31.  
  32. #define MAX_WARNINGS 3
  33.  
  34. new VehicleNames[212][] = {
  35. {"Landstalker"},{"Bravura"},{"Buffalo"},{"Linerunner"},{"Perrenial"},{"Sentinel"},{"Dumper"},
  36. {"Firetruck"},{"Trashmaster"},{"Stretch"},{"Manana"},{"Infernus"},{"Voodoo"},{"Pony"},{"Mule"},
  37. {"Cheetah"},{"Ambulance"},{"Leviathan"},{"Moonbeam"},{"Esperanto"},{"Taxi"},{"Washington"},
  38. {"Bobcat"},{"Mr Whoopee"},{"BF Injection"},{"Hunter"},{"Premier"},{"Enforcer"},{"Securicar"},
  39. {"Banshee"},{"Predator"},{"Bus"},{"Rhino"},{"Barracks"},{"Hotknife"},{"Trailer 1"},{"Previon"},
  40. {"Coach"},{"Cabbie"},{"Stallion"},{"Rumpo"},{"RC Bandit"},{"Romero"},{"Packer"},{"Monster"},
  41. {"Admiral"},{"Squalo"},{"Seasparrow"},{"Pizzaboy"},{"Tram"},{"Trailer 2"},{"Turismo"},
  42. {"Speeder"},{"Reefer"},{"Tropic"},{"Flatbed"},{"Yankee"},{"Caddy"},{"Solair"},{"Berkley's RC Van"},
  43. {"Skimmer"},{"PCJ-600"},{"Faggio"},{"Freeway"},{"RC Baron"},{"RC Raider"},{"Glendale"},{"Oceanic"},
  44. {"Sanchez"},{"Sparrow"},{"Patriot"},{"Quad"},{"Coastguard"},{"Dinghy"},{"Hermes"},{"Sabre"},
  45. {"Rustler"},{"ZR-350"},{"Walton"},{"Regina"},{"Comet"},{"BMX"},{"Burrito"},{"Camper"},{"Marquis"},
  46. {"Baggage"},{"Dozer"},{"Maverick"},{"News Chopper"},{"Rancher"},{"FBI Rancher"},{"Virgo"},{"Greenwood"},
  47. {"Jetmax"},{"Hotring"},{"Sandking"},{"Blista Compact"},{"Police Maverick"},{"Boxville"},{"Benson"},
  48. {"Mesa"},{"RC Goblin"},{"Hotring Racer A"},{"Hotring Racer B"},{"Bloodring Banger"},{"Rancher"},
  49. {"Super GT"},{"Elegant"},{"Journey"},{"Bike"},{"Mountain Bike"},{"Beagle"},{"Cropdust"},{"Stunt"},
  50. {"Tanker"}, {"Roadtrain"},{"Nebula"},{"Majestic"},{"Buccaneer"},{"Shamal"},{"Hydra"},{"FCR-900"},
  51. {"NRG-500"},{"HPV1000"},{"Cement Truck"},{"Tow Truck"},{"Fortune"},{"Cadrona"},{"FBI Truck"},
  52. {"Willard"},{"Forklift"},{"Tractor"},{"Combine"},{"Feltzer"},{"Remington"},{"Slamvan"},
  53. {"Blade"},{"Freight"},{"Streak"},{"Vortex"},{"Vincent"},{"Bullet"},{"Clover"},{"Sadler"},
  54. {"Firetruck LA"},{"Hustler"},{"Intruder"},{"Primo"},{"Cargobob"},{"Tampa"},{"Sunrise"},{"Merit"},
  55. {"Utility"},{"Nevada"},{"Yosemite"},{"Windsor"},{"Monster A"},{"Monster B"},{"Uranus"},{"Jester"},
  56. {"Sultan"},{"Stratum"},{"Elegy"},{"Raindance"},{"RC Tiger"},{"Flash"},{"Tahoma"},{"Savanna"},
  57. {"Bandito"},{"Freight Flat"},{"Streak Carriage"},{"Kart"},{"Mower"},{"Duneride"},{"Sweeper"},
  58. {"Broadway"},{"Tornado"},{"AT-400"},{"DFT-30"},{"Huntley"},{"Stafford"},{"BF-400"},{"Newsvan"},
  59. {"Tug"},{"Trailer 3"},{"Emperor"},{"Wayfarer"},{"Euros"},{"Hotdog"},{"Club"},{"Freight Carriage"},
  60. {"Trailer 3"},{"Andromada"},{"Dodo"},{"RC Cam"},{"Launch"},{"Police Car (LSPD)"},{"Police Car (SFPD)"},
  61. {"Police Car (LVPD)"},{"Police Ranger"},{"Picador"},{"S.W.A.T. Van"},{"Alpha"},{"Phoenix"},{"Glendale"},
  62. {"Sadler"},{"Luggage Trailer A"},{"Luggage Trailer B"},{"Stair Trailer"},{"Boxville"},{"Farm Plow"},
  63. {"Utility Trailer"}
  64. };
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73. enum sInfo
  74. {
  75.     sPlayers,
  76.     sBans,
  77.     sKicks,
  78.     sWarns,
  79.     sMutes,
  80.     sKills,
  81.     sDeaths
  82. }
  83.  
  84. new ServerInfo[MAX_PLAYERS][sInfo];
  85.  
  86. enum pInfo
  87. {
  88.     pRegistered,
  89.     pLoggedIn,
  90.     pKicks,
  91.     pWarns,
  92.     pCWarns,
  93.     pBanned,
  94.     pPass,
  95.     pCash,
  96.     pScore,
  97.     pAdmin,
  98.     pKills,
  99.     pDeaths,
  100.     pVip,
  101.     pRank,
  102. }
  103. new PlayerInfo[MAX_PLAYERS][pInfo];
  104.  
  105. forward LoadUser_data(playerid,name[],value[]);
  106. public LoadUser_data(playerid,name[],value[])
  107. {
  108.     INI_Int("Registered",PlayerInfo[playerid][pRegistered]);
  109.     INI_Int("LoggedIn",PlayerInfo[playerid][pLoggedIn]);
  110.     INI_Int("Kicks",PlayerInfo[playerid][pKicks]);
  111.     INI_Int("Warns",PlayerInfo[playerid][pWarns]);
  112.     INI_Int("CurrentWarns",PlayerInfo[playerid][pCWarns]);
  113.     INI_Int("Banned",PlayerInfo[playerid][pBanned]);
  114.     INI_Int("Password",PlayerInfo[playerid][pPass]);
  115.     INI_Int("Cash",PlayerInfo[playerid][pCash]);
  116.     INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
  117.     INI_Int("Kills",PlayerInfo[playerid][pKills]);
  118.     INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
  119.     INI_Int("VipType",PlayerInfo[playerid][pVip]);
  120.     INI_Int("Rank",PlayerInfo[playerid][pRank]);
  121.     return 1;
  122. }
  123.  
  124. stock UserPath(playerid)
  125. {
  126.     new string[128],playername[MAX_PLAYER_NAME];
  127.     GetPlayerName(playerid,playername,sizeof(playername));
  128.     format(string,sizeof(string),PATH,playername);
  129.     return string;
  130. }
  131.  
  132. /*Credits to Dracoblue*/
  133. stock udb_hash(buf[])
  134. {
  135. new length=strlen(buf);
  136. new s1 = 1;
  137. new s2 = 0;
  138. new n;
  139. for (n=0; n<length; n++)
  140. {
  141. s1 = (s1 + buf[n]) % 65521;
  142. s2 = (s2 + s1) % 65521;
  143. }
  144. return (s2 << 16) + s1;
  145. }
  146.  
  147.  
  148. main()
  149. {
  150.         print("\n----------------------------------");
  151.         print(" Blank Gamemode by your name here");
  152.         print("----------------------------------\n");
  153. }
  154.  
  155. public OnGameModeInit()
  156. {
  157.         SetGameModeText("World War lll");
  158.        
  159.         INI_Load("serverdata.ini");
  160.         return 1;
  161. }
  162.  
  163. public OnGameModeExit()
  164. {
  165.         return 1;
  166. }
  167.  
  168. public OnPlayerRequestClass(playerid, classid)
  169. {
  170.         return 1;
  171. }
  172.  
  173. public OnPlayerConnect(playerid)
  174. {
  175.     if(fexist(UserPath(playerid)))
  176.     {
  177.         INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  178.         ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
  179.     }
  180.     else
  181.     {
  182.         ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
  183.     }
  184.    
  185.     return 1;
  186. }
  187.  
  188. public OnPlayerDisconnect(playerid, reason)
  189. {
  190.     new INI:File = INI_Open(UserPath(playerid));
  191.     INI_SetTag(File,"data");
  192.     INI_WriteInt(File,"Registered",PlayerInfo[playerid][pRegistered]);
  193.     INI_WriteInt(File,"LoggedIn",PlayerInfo[playerid][pLoggedIn]);
  194.     INI_WriteInt(File,"Kicks",PlayerInfo[playerid][pKicks]);
  195.     INI_WriteInt(File,"Warns",PlayerInfo[playerid][pWarns]);
  196.     INI_WriteInt(File,"CurrentWarns",PlayerInfo[playerid][pCWarns]);
  197.     INI_WriteInt(File,"Banned",PlayerInfo[playerid][pBanned]);
  198.     INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
  199.     INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
  200.     INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
  201.     INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
  202.     INI_WriteInt(File,"VipType",PlayerInfo[playerid][pVip]);
  203.     INI_WriteInt(File,"Rank",PlayerInfo[playerid][pRank]);
  204.     INI_Close(File);
  205.     return 1;
  206. }
  207.  
  208. public OnPlayerSpawn(playerid)
  209. {
  210.         return 1;
  211. }
  212.  
  213. public OnPlayerDeath(playerid, killerid, reason)
  214. {
  215.     PlayerInfo[killerid][pKills]++;
  216.     PlayerInfo[playerid][pDeaths]++;
  217.     PlayerInfo[playerid][pScore] += 2;
  218.    
  219.     ServerInfo[playerid][sKills]++;
  220.     ServerInfo[playerid][sDeaths]++;
  221.     return 1;
  222. }
  223.  
  224. public OnVehicleSpawn(vehicleid)
  225. {
  226.         return 1;
  227. }
  228.  
  229. public OnVehicleDeath(vehicleid, killerid)
  230. {
  231.         return 1;
  232. }
  233.  
  234. public OnPlayerText(playerid, text[])
  235. {
  236.  
  237.     //Admin Chat
  238.     if(PlayerInfo[playerid][pAdmin] >= 1 && text[0] == '#')
  239.     {
  240.         new msg[128], pName[MAX_PLAYER_NAME];
  241.         GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
  242.         format(msg, sizeof(msg), "(Admin Chat) %s: %s", pName, text[1]);
  243.         SendMessageToAdmins(msg);
  244.     }
  245.    
  246.     //VIP Chat
  247.         return 1;
  248. }
  249.  
  250. public OnPlayerCommandText(playerid, cmdtext[])
  251. {
  252.     //RCON Commands
  253.     dcmd(unbanip, 7, cmdtext);
  254.    
  255.     //Admin Commands
  256.     dcmd(car, 3, cmdtext);
  257.     dcmd(sethealth, 9, cmdtext);
  258.     dcmd(kick, 4, cmdtext);
  259.     dcmd(ban, 3, cmdtext);
  260.     dcmd(warn, 4, cmdtext);
  261.     dcmd(advehicles, 10, cmdtext);
  262.     dcmd(setvip, 6, cmdtext);
  263.     dcmd(stats, 5, cmdtext);
  264.     return 1;
  265. }
  266.  
  267.  
  268. dcmd_unbanip(playerid, params[])
  269. {
  270.     new ip;
  271.     new string[10];
  272.    
  273.     if(IsPlayerAdmin(playerid))
  274.     {
  275.         if(sscanf(params,"z", ip)) SendClientMessage(playerid, COLOR_RED, "Usage: /unbanip (IP address)");
  276.         {
  277.             format(string,sizeof(string),"unbanip %s",ip);
  278.             SendRconCommand(string);
  279.             SendClientMessage(playerid, COLOR_RED, "You have sucessfully unbanned IP %s");
  280.         }
  281.     }
  282.     else SendClientMessage(playerid, COLOR_RED, "ERROR: You must be logged into RCON to use this command");
  283.     return 1;
  284. }
  285.  
  286. dcmd_car(playerid,params[])
  287. {
  288.     if(PlayerInfo[playerid][pAdmin] >= 2)
  289.     {
  290.         new Index;
  291.         new tmp[256];  tmp  = strtok(params,Index);
  292.         new tmp2[256]; tmp2 = strtok(params,Index);
  293.         new tmp3[256]; tmp3 = strtok(params,Index);
  294.         if(!strlen(tmp)) return
  295.         SendClientMessage(playerid, COLOR_RED, "Usage: /car (Model ID/Name) (Optional: Colour1) (Optional: Colour2)");
  296.  
  297.         new car;
  298.         new string[128];
  299.         new colour1, colour2;
  300.         if(!IsNumeric(tmp))
  301.         car = GetVehicleModelIDFromName(tmp);
  302.         else car = strval(tmp);
  303.         if(car < 400 || car > 611) return  SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid Vehicle Model ID!");
  304.         if(!strlen(tmp2)) colour1 = random(126); else colour1 = strval(tmp2);
  305.         if(!strlen(tmp3)) colour2 = random(126); else colour2 = strval(tmp3);
  306.  
  307.         new LVehicleID;
  308.         new Float:X,Float:Y,Float:Z;
  309.         new Float:Angle,int1;
  310.         GetPlayerPos(playerid, X,Y,Z);
  311.         GetPlayerFacingAngle(playerid,Angle);
  312.         int1 = GetPlayerInterior(playerid);
  313.         LVehicleID = CreateVehicle(car, X+3,Y,Z, Angle, colour1, colour2, -1);
  314.         LinkVehicleToInterior(LVehicleID,int1);
  315.         format(string, sizeof(string), "-| You have Spawned a \"%s\" (Model: %d) with Colours: %d,%d |-", VehicleNames[car-400], car, colour1, colour2);
  316.         return SendClientMessage(playerid,COLOR_AQUA, string);
  317.     }
  318.     else return SendClientMessage(playerid, COLOR_RED, "ERROR: You need to be level 2 to use this command");
  319. }
  320.  
  321.  
  322. dcmd_sethealth(playerid, params[])
  323. {
  324.     if(PlayerInfo[playerid][pAdmin] == 4 || IsPlayerAdmin(playerid)) // IsPlayerAdmin check (we want only RCON admins to use this command (error message at bottom if the player isn't logged into RCON)
  325.     {
  326.         new id, Float:amount, string[70], pname[MAX_PLAYER_NAME]; // Create the variables needed for this command. id = the id we want to set the health of, amount = the amount we're gonna set id's health to and pName is just where we store id's name.
  327.         if(sscanf(params, "uf", id, amount)) return SendClientMessage(playerid, COLOR_RED, "Usage: /sethealth (id) (amount)");
  328.  
  329.         if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "ERROR: Player not found."); // ID is not connected, send an error message
  330.             else
  331.         {
  332.             GetPlayerName(id, pname, MAX_PLAYER_NAME);
  333.             SetPlayerHealth(id, amount);
  334.             format(string, sizeof(string), "-| You have set %s(%d)'s health to %d |-", pname, id, amount);
  335.             SendClientMessage(playerid, COLOR_AQUA, string);
  336.             return 1;
  337.         }
  338.     }
  339.     else SendClientMessage(playerid, COLOR_RED, "ERROR: You need to be Level 4 to use this command.");
  340.     return 1;
  341. }
  342.  
  343. dcmd_kick(playerid, params[])
  344. {
  345.     if(PlayerInfo[playerid][pAdmin] == 4 || IsPlayerAdmin(playerid))
  346.     {
  347.         new id;
  348.         new reason[64];
  349.         new idName[MAX_PLAYER_NAME];
  350.         new playeridName[MAX_PLAYER_NAME];
  351.        
  352.         if(sscanf(params,"uz", id, reason)) SendClientMessage(playerid, 0xFF0000FF, "Usage: /kick (id) (reason)");
  353.         else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000FF, "ERROR: Player not found");
  354.         else
  355.         {
  356.             new str_out[128];//ADDED
  357.             GetPlayerName(id, idName, MAX_PLAYER_NAME);
  358.             GetPlayerName(playerid, playeridName, MAX_PLAYER_NAME);
  359.             format(str_out,sizeof str_out,"You have been kicked by Administrator %s. Reason: %s", playeridName, reason);//added
  360.             SendClientMessage(id, 0xFF0000FF,str_out); //Line 190  //changed
  361.             Kick(id);
  362.             format(str_out,sizeof str_out,"You have succesfully kicked %s for reason: %s", idName, reason);//added
  363.             SendClientMessage(playerid, COLOR_RED, str_out); //Line 192  //changed
  364.            
  365.             ServerInfo[playerid][sKicks]++;
  366.             PlayerInfo[playerid][pKicks]++;
  367.             return 1;
  368.         }
  369.     }
  370.     else SendClientMessage(playerid, COLOR_RED, "ERROR: You need to be Level 4 to use this command.");
  371.     return 1;
  372. }
  373.  
  374. dcmd_ban(playerid, params[])
  375. {
  376.     if(PlayerInfo[playerid][pAdmin] == 5 || IsPlayerAdmin(playerid))
  377.     {
  378.         new
  379.             id,
  380.             reason[64],
  381.             string1[59],
  382.             string2[41],
  383.             string3[49],
  384.             pname[MAX_PLAYER_NAME],
  385.             pnametwo[MAX_PLAYER_NAME];
  386.            
  387.         if (sscanf(params, "uz", id, reason)) SendClientMessage(playerid, COLOR_RED, "Usage: \"/ban <playerid/partname> <reason (optional)>\"");
  388.         else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_RED, "ERROR: Player not found");
  389.         else
  390.         {
  391.             GetPlayerName(playerid, pname, sizeof(pname));
  392.             GetPlayerName(id, pnametwo, sizeof(pnametwo));
  393.  
  394.             format(string1,sizeof(string1),"-| You have been banned by administrator %s | Reason: %s", pname, reason);
  395.             SendClientMessage(id, COLOR_RED, string1);
  396.  
  397.             format(string2,sizeof(string2),"-| You have banned %s(%d) | Reason: %s", pnametwo, id, reason);
  398.             SendClientMessage(playerid, COLOR_RED, string2);
  399.  
  400.             format(string3,sizeof(string3),"-| Administrator %s has banned %s | Reason: %s |-", pname, pnametwo, reason);
  401.             SendClientMessageToAll(COLOR_RED, string3);
  402.            
  403.             BanEx(id, reason);
  404.         }
  405.     }
  406.     SendClientMessage(playerid, COLOR_RED, "ERROR: You need to be level 5 to use this command");
  407.     return 1;
  408. }
  409.  
  410. dcmd_warn(playerid, params[])
  411. {
  412.     new
  413.         id,
  414.         string[58],
  415.         string2[53],
  416.         string3[64],
  417.         string4[53],
  418.         string5[63],
  419.         pname1[MAX_PLAYER_NAME],
  420.         pname2[MAX_PLAYER_NAME],
  421.         reason[64];
  422.        
  423.         if(PlayerInfo[playerid][pAdmin] == 3 || IsPlayerAdmin(playerid))
  424.         {
  425.             if(sscanf(params,"uz", id, reason)) SendClientMessage(playerid, COLOR_RED, "Usage: /warn (id) (reason)");
  426.             {
  427.                 GetPlayerName(playerid, pname1, sizeof(pname1));
  428.                 GetPlayerName(id, pname2, sizeof(pname2));
  429.                
  430.                 if(PlayerInfo[id][pCWarns] == 1)
  431.                 {
  432.                     format(string2,sizeof(string2),"-| You have been warned [Warning 1/3] | Reason: %s |-", reason);
  433.                     SendClientMessage(id, COLOR_YELLOW, string2);
  434.                    
  435.                     format(string3,sizeof(string3),"-| Administrator %s has warned %s [Warning 1/3] | Reason: %s |-", pname1, pname2, reason);
  436.                     SendClientMessageToAll(COLOR_YELLOW, string3);
  437.                    
  438.                     PlayerInfo[id][pCWarns] = 1;
  439.                     PlayerInfo[id][pWarns]++;
  440.                 }
  441.                
  442.                 else if(PlayerInfo[id][pCWarns] == 2)
  443.                 {
  444.                     format(string4,sizeof(string4),"-| You have been warned [Warning 2/3] | Reason: %s |-", reason);
  445.                     SendClientMessage(id, COLOR_YELLOW, string4);
  446.                    
  447.                     format(string5,sizeof(string5),"-| Administrator %s has warned %s [Warning 2/3] | Reason: %s |-", pname1, pname2, reason);
  448.                     SendClientMessageToAll(COLOR_YELLOW, string5);
  449.                    
  450.                     PlayerInfo[id][pCWarns] = 2;
  451.                     PlayerInfo[id][pWarns]++;
  452.                 }
  453.                
  454.                 else if(PlayerInfo[id][pCWarns] == 3)
  455.                 {
  456.                     format(string,sizeof(string),"-| Player %s has had 3 warnings! He will now be kicked. |-", pname2);
  457.                     SendClientMessageToAll(COLOR_YELLOW, string);
  458.                     INI_Open(UserPath(playerid));
  459.                     PlayerInfo[id][pCWarns] = 0;
  460.                     Kick(id);
  461.                     return PlayerInfo[playerid][pCWarns] = 0;
  462.                 }
  463.             }
  464.         }
  465.         else return SendClientMessage(playerid, COLOR_RED, "ERROR: You need to be Level 3 to use this command");
  466.     return 1;
  467. }
  468.  
  469.  
  470.  
  471.  
  472. dcmd_advehicles(playerid, params[])
  473. {
  474.     #pragma unused params
  475.     if(PlayerInfo[playerid][pAdmin] == 2 || IsPlayerAdmin(playerid))
  476.     {
  477.         ShowPlayerDialog(playerid, DIALOG_ADVEHICLES, DIALOG_STYLE_LIST, "Admin Vehicles", "Rhino\nHydra\nPatriot\nHunter\nMaverick\nS.W.A.T. Van\nBarracks\nFiretruck", "Spawn", "Cancel");
  478.     }
  479.     else SendClientMessage(playerid, 0xFF0000FF, "ERROR: You need to be Level 2 to use this command");
  480.     return 1;
  481. }
  482.  
  483. dcmd_setvip(playerid,params[])
  484. {
  485.     if(PlayerInfo[playerid][pLoggedIn] == 1)
  486.     {
  487.         if(PlayerInfo[playerid][pAdmin] >= 5 || IsPlayerAdmin(playerid))
  488.         {
  489.             new tmp [256];
  490.             new tmp2[256];
  491.             new Index;
  492.             tmp  = strtok(params,Index);
  493.             tmp2 = strtok(params,Index);
  494.             if(!strlen(params)) return
  495.             SendClientMessage(playerid, COLOR_RED, "Usage: /setvip (Player ID) (AccountType [0-5])");
  496.  
  497.             new player1, type, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
  498.             player1 = strval(tmp);
  499.             if(!strlen(tmp2)) return
  500.             SendClientMessage(playerid, COLOR_RED, "Usage: /setvip (Player ID) (AccountType [0-5])");
  501.             type = strval(tmp2);
  502.  
  503.             if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID)
  504.             {
  505.                 if(PlayerInfo[player1][pLoggedIn] == 1)
  506.                 {
  507.                 if(type > 5)
  508.                 return SendClientMessage(playerid,COLOR_RED,"ERROR: Invalid VIP Type!");
  509.                 if(type == PlayerInfo[player1][pVip])
  510.                 return SendClientMessage(playerid,COLOR_RED,"ERROR: Player is already this VIP level.");
  511.                 GetPlayerName(player1, playername, sizeof(playername));
  512.                 GetPlayerName(playerid, adminname, sizeof(adminname));
  513.  
  514.                 if(type > 0)
  515.                 format(string,sizeof(string),"-| Administrator %s has set your VIP Type to TYPE %d |-",adminname,type);
  516.                 else
  517.                 format(string,sizeof(string),"|- Administrator %s has set your VIP Type to TYPE 0. |-",adminname);
  518.                 SendClientMessage(player1, COLOR_AQUA, string);
  519.  
  520.                 format(string,sizeof(string),"-| You have given %s Account Type: %s |-", playername, type);
  521.                 SendClientMessage(playerid,COLOR_AQUA,string);
  522.                
  523.                 new INI:File = INI_Open(UserPath(playerid));
  524.                 INI_Open(File);
  525.                 INI_WriteInt(File,"VipType",type);
  526.                 INI_Close(File);
  527.                 PlayerInfo[player1][pVip] = type;
  528.                 }
  529.                 return SendClientMessage(playerid,COLOR_RED,"ERROR: This player is not logged in");
  530.             }
  531.             else return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected");
  532.         }
  533.         else return SendClientMessage(playerid, COLOR_RED, "ERROR: You must be level 6 or RCON admin to use this command");
  534.     }
  535.     else return SendClientMessage(playerid,COLOR_RED,"ERROR: You must be logged in to use this command.");
  536. }
  537.  
  538. dcmd_stats(playerid)
  539. {
  540.     new string[
  541.     new pName[MAX_PLAYER_NAME];
  542.  
  543.     new Float: health;
  544.     GetPlayerHeath(playerid, health);
  545.    
  546.     new Float: armour;
  547.     GetPlayerArmour(playerid, armour);
  548.    
  549.     new pIP[16];
  550.     GetPlayerIp(playerid, pIP, sizeof(pIP));
  551.    
  552.     GetPlayerName(playerid, pName, sizeof(pName));
  553.    
  554.     format(string,sizeof(string),"-| Your Stats (%s) |-", pName);
  555.     SendClientMessage(playerid, COLOR_AQUA, string);
  556.     format(string,sizeof(string),"Name: %s - IP: %s - Health: %d - Armour: %d - Money: $%d", pName, pIP, floatround(health), floatround(armour), GetPlayerMoney(playerid));DestroyAllDynamicObjects()
  557.            
  558.  
  559. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  560. {
  561.     return 1;
  562. }
  563.  
  564. public OnPlayerExitVehicle(playerid, vehicleid)
  565. {
  566.     return 1;
  567. }
  568.  
  569. public OnPlayerStateChange(playerid, newstate, oldstate)
  570. {
  571.         return 1;
  572. }
  573.  
  574. public OnPlayerEnterCheckpoint(playerid)
  575. {
  576.         return 1;
  577. }
  578.  
  579. public OnPlayerLeaveCheckpoint(playerid)
  580. {
  581.         return 1;
  582. }
  583.  
  584. public OnPlayerEnterRaceCheckpoint(playerid)
  585. {
  586.         return 1;
  587. }
  588.  
  589. public OnPlayerLeaveRaceCheckpoint(playerid)
  590. {
  591.         return 1;
  592. }
  593.  
  594. public OnRconCommand(cmd[])
  595. {
  596.         return 1;
  597. }
  598.  
  599. public OnPlayerRequestSpawn(playerid)
  600. {
  601.         return 1;
  602. }
  603.  
  604. public OnObjectMoved(objectid)
  605. {
  606.         return 1;
  607. }
  608.  
  609. public OnPlayerObjectMoved(playerid, objectid)
  610. {
  611.         return 1;
  612. }
  613.  
  614. public OnPlayerPickUpPickup(playerid, pickupid)
  615. {
  616.         return 1;
  617. }
  618.  
  619. public OnVehicleMod(playerid, vehicleid, componentid)
  620. {
  621.         return 1;
  622. }
  623.  
  624. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  625. {
  626.         return 1;
  627. }
  628.  
  629. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  630. {
  631.         return 1;
  632. }
  633.  
  634. public OnPlayerSelectedMenuRow(playerid, row)
  635. {
  636.         return 1;
  637. }
  638.  
  639. public OnPlayerExitedMenu(playerid)
  640. {
  641.         return 1;
  642. }
  643.  
  644. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  645. {
  646.         return 1;
  647. }
  648.  
  649. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  650. {
  651.         return 1;
  652. }
  653.  
  654. public OnRconLoginAttempt(ip[], password[], success)
  655. {
  656.         return 1;
  657. }
  658.  
  659. public OnPlayerUpdate(playerid)
  660. {
  661.         return 1;
  662. }
  663.  
  664. public OnPlayerStreamIn(playerid, forplayerid)
  665. {
  666.         return 1;
  667. }
  668.  
  669. public OnPlayerStreamOut(playerid, forplayerid)
  670. {
  671.         return 1;
  672. }
  673.  
  674. public OnVehicleStreamIn(vehicleid, forplayerid)
  675. {
  676.         return 1;
  677. }
  678.  
  679. public OnVehicleStreamOut(vehicleid, forplayerid)
  680. {
  681.         return 1;
  682. }
  683.  
  684. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  685. {
  686.     switch(dialogid)
  687.     {
  688.         case DIALOG_REGISTER:
  689.         {
  690.             if (IsPlayerNPC(playerid)) return 1;
  691.             if (!response) return Kick(playerid);
  692.             if(response)
  693.             {
  694.                 if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
  695.                 new INI:File = INI_Open(UserPath(playerid));
  696.                 INI_SetTag(File,"data");
  697.                 INI_WriteInt(File,"Registered",1);
  698.                 INI_WriteInt(File,"LoggedIn",0);
  699.                 INI_WriteInt(File,"Kicks",0);
  700.                 INI_WriteInt(File,"Warns",0);
  701.                 INI_WriteInt(File,"Mutes",0);
  702.                 INI_WriteInt(File,"Banned",0);
  703.                 INI_WriteInt(File,"Password",udb_hash(inputtext));
  704.                 INI_WriteInt(File,"Cash",0);
  705.                 INI_WriteInt(File,"Admin",0);
  706.                 INI_WriteInt(File,"Kills",0);
  707.                 INI_WriteInt(File,"Deaths",0);
  708.                 INI_WriteInt(File,"VipType",0);
  709.                 INI_WriteInt(File,"Rank",0);
  710.                 INI_Close(File);
  711.                
  712.                 ServerInfo[playerid][sPlayers]++;
  713.  
  714.                 ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Great! Your Y_INI system works perfectly. Relog to save your stats!","Ok","");
  715.                         }
  716.         }
  717.  
  718.         case DIALOG_LOGIN:
  719.         {
  720.             if(IsPlayerNPC(playerid)) return 1;
  721.             if ( !response ) return Kick ( playerid );
  722.             if( response )
  723.             {
  724.                 if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
  725.                 {
  726.                     INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  727.                     GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
  728.                     ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
  729.                     PlayerInfo[playerid][pLoggedIn] = 1;
  730.                 }
  731.                 else
  732.                 {
  733.                     ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
  734.                 }
  735.                 return 1;
  736.             }
  737.         }
  738.  
  739.         case DIALOG_ADVEHICLES:
  740.         {
  741.             if(response)
  742.             {
  743.                 switch(listitem)
  744.                 {
  745.                     case 0:
  746.                     {
  747.                     CreateVehicleForPlayer(playerid, "432", -1, -1, 1000);
  748.                     }
  749.                     case 1:
  750.                     {
  751.                         CreateVehicleForPlayer(playerid, "520", -1, -1, 1000);
  752.                     }
  753.                     case 2:
  754.                     {
  755.                         CreateVehicleForPlayer(playerid, "470", -1, -1, 1000);
  756.                     }
  757.                     case 3:
  758.                     {
  759.                         CreateVehicleForPlayer(playerid, "425", -1, -1, 1000);
  760.                     }
  761.                     case 4:
  762.                     {
  763.                         CreateVehicleForPlayer(playerid, "487", -1, -1, 1000);
  764.                     }
  765.                     case 5:
  766.                     {
  767.                         CreateVehicleForPlayer(playerid, "601", -1, -1, 1000);
  768.                     }
  769.                     case 6:
  770.                     {
  771.                         CreateVehicleForPlayer(playerid, "433", -1, -1, 1000);
  772.                     }
  773.                     case 7:
  774.                     {
  775.                         CreateVehicleForPlayer(playerid, "407", -1, -1, 1000);
  776.                     }
  777.                 }
  778.             }
  779.         }
  780.         default:
  781.         {
  782.             SendClientMessage(playerid, 0xFF0000FF, "You have cancelled!");
  783.             switch(listitem)
  784.             {
  785.                 case 0:
  786.                 {
  787.                     //Selected Item: "Rhino"
  788.                 }
  789.                 case 1:
  790.                 {
  791.                     //Selected Item: "Hydra"
  792.                 }
  793.                 case 2:
  794.                 {
  795.                     //Selected Item: "Patriot"
  796.                 }
  797.                 case 3:
  798.                 {
  799.                     //Selected Item: "Hunter"
  800.                 }
  801.                 case 4:
  802.                 {
  803.                     //Selected Item: "Maverick"
  804.                 }
  805.                 case 5:
  806.                 {
  807.                     //Selected Item: "S.W.A.T. Van"
  808.                 }
  809.                 case 6:
  810.                 {
  811.                     //Selected Item: "Barracks"
  812.                 }
  813.                 case 7:
  814.                 {
  815.                     //Selected Item: "Firetruck"
  816.                 }
  817.             }
  818.         }
  819.     }
  820.     return 1;
  821. }
  822.  
  823. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  824. {
  825.         return 1;
  826. }
  827.  
  828. stock pname()
  829. {
  830.     new pname;
  831.     GetPlayerName(playerid, pname, sizeof(pname));
  832.     return 1;
  833. }
  834.  
  835.  
  836.  
  837. strtok(const string[], &index)
  838. {
  839.     new length = strlen(string);
  840.     while ((index < length) && (string[index] <= ' '))
  841.     {
  842.         index++;
  843.     }
  844.  
  845.     new offset = index;
  846.     new result[20];
  847.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  848.     {
  849.         result[index - offset] = string[index];
  850.         index++;
  851.     }
  852.     result[index - offset] = EOS;
  853.     return result;
  854. }
  855.  
  856. GetVehicleModelIDFromName(vname[])
  857. {
  858.     for(new i = 0; i < 211; i++)
  859.     {
  860.     if ( strfind(VehicleNames[i], vname, true) != -1 )
  861.     return i + 400;
  862.     }
  863.     return -1;
  864. }
  865.  
  866. stock IsNumeric(string[])
  867. {
  868.     for (new i = 0, j = strlen(string);
  869.     i < j; i++)
  870.     {
  871.     if (string[i] > '9' || string[i] < '0')
  872.     return 0;
  873.     }
  874.     return 1;
  875. }
  876.  
  877. stock LoadServerData()
  878. {
  879.     INI_Load("serverdata.ini");
  880.     print("serverdata.ini Loaded!");
  881.     return 1;
  882. }
  883.  
  884. stock OpenServerDataFile()
  885. {
  886.     INI_Open("serverdata.ini);
  887.     return 1;
  888. }
  889.  
  890. stock CloseServerDataFile()
  891. {
  892.     INI_Close("serverdata.ini");
  893.     return 1;
  894. }
  895.  
  896. stock GetVehicleName(modelid)
  897. {
  898.     return VehicleNames[modelid-400];
  899. }
  900.  
  901. stock SendMessageToAdmins(text[])
  902. {
  903.     for(new i = 0, i < MAX_PLAYERS, i++)
  904.     {
  905.         if(IsPlayerAdmin(i))
  906.         {
  907.             SendClientMessage(i, -1, text);
  908.         }
  909.     }
  910. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement