Advertisement
Guest User

Gangz Wars - By Avi

a guest
Aug 9th, 2012
395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 18.61 KB | None | 0 0
  1. // Starting Gangz War
  2. // GM created By Avi is 100% from scratch and it does not have any Fs or anything !
  3. //////////////////////////// Thanks For Download /////////////////////////////////
  4. /////////////////////////////Please Rep Me if You Like It ! //////////////////////
  5.  
  6. ////////////////////////////////////////////// Includes
  7. #include <a_samp>
  8. #include <YSI\y_ini>  //If you have installed YSI, then you shouldn't have any problem
  9.  
  10. /////////////////////////////////////////////// Teams
  11. #define Grove 1
  12. #define Ballas 2
  13.  
  14. #define GroveColor   0x90EE90FF
  15. #define BallasColor  0xFFC0CBAA
  16.  
  17. /////////////////////////////////////////////// Defines
  18. #define DIALOG_HELP 5
  19. #define DIALOG_GHELP 6
  20. #define DIALOG_BHELP 7
  21. #define DIALOG_OHELP 8
  22. #define DIALOG_RULES 10
  23. #define DIALOG_CMDS 11
  24. #define MAX_FLOODLINES 12
  25. #define MAX_FLOOD_RATE_SECS 5000
  26. #define dregister 2011 //Defining register dialog so it won't mixed up with the other dialogs
  27. #define dlogin 2012 //Defining login dialog so it won't mixed up with the other dialogs
  28. #define UserPath "Users/%s.ini" //Will define user's account path. In this case, we will save it in Scriptfiles/Users. So create a file inside of your Scriptfiles folder called Users
  29.  
  30. //////////////////////////////////////////////// Others
  31. native WP_Hash(buffer[],len,const str[]); // Whirlpool native, add it at the top of your script under includes
  32.  
  33. ///////////////////////////////////////////////// Enums
  34. enum PlayerInfo
  35. {
  36.     Pass[129], //User's password
  37.     Adminlevel, //User's admin level
  38.     VIPlevel, //User's vip level
  39.     Money, //User's money
  40.     Scores, //User's scores
  41.     Kills, //User's kills
  42.     Deaths //User's deaths
  43. }
  44. new pInfo[MAX_PLAYERS][PlayerInfo];
  45.  
  46. ///////////////////////////////////////////////// Stocks
  47. stock Path(playerid) //Will create a new stock so we can easily use it later to load/save user's data in user's path
  48. {
  49.     new str[128],name[MAX_PLAYER_NAME];
  50.     GetPlayerName(playerid,name,sizeof(name));
  51.     format(str,sizeof(str),UserPath,name);
  52.     return str;
  53. }
  54.  
  55. ///////////////////////////////////////////////// Forwards
  56. forward loadaccount_user(playerid, name[], value[]); //forwarding a new function to load user's data
  57. public loadaccount_user(playerid, name[], value[])
  58. {
  59.     INI_String("Password", pInfo[playerid][Pass],129); /*we will use INI_String to load user's password.
  60.     ("Password",.. will load user's password inside of user's path. 'pInfo[playerid][Pass]',...We have defined our user's variable above called, pInfo. Now it's time to use it here to load user's password. '129',... 129 is a length of a hashed user's password. Whirlpool will hash 128 characters + NULL*/
  61.     INI_Int("AdminLevel",pInfo[playerid][Adminlevel]);/*We will use INI_Int to load user's admin level. INI_Int stands for INI_Integer. This load an admin level. */
  62.     INI_Int("VIPLevel",pInfo[playerid][VIPlevel]);//As explained above
  63.     INI_Int("Money",pInfo[playerid][Money]); //As explained above
  64.     INI_Int("Scores",pInfo[playerid][Scores]);//As explained above
  65.     INI_Int("Kills",pInfo[playerid][Kills]);//As explained above
  66.     INI_Int("Deaths",pInfo[playerid][Deaths]);//As explained above
  67.     return 1;
  68. }
  69.  
  70. new randomMessages[][] =  //here, we're creating the array with the name "randomMessages"
  71.     {
  72.         "[SERVER MESSAGE] Please Change It !", //this is the text of your first message
  73.         "[SERVER MESSAGE] Please Change It !", //this is the text of your second message
  74.         "[SERVER MESSAGE] Thsi Too!" //this is the text of your third message
  75.     };
  76.  
  77. forward RandomMessages();
  78. public RandomMessages()
  79. {
  80.     new randomMsg = random(sizeof(randomMessages));
  81.     SendClientMessageToAll(BallasColor, randomMessages[randomMsg]);
  82. }
  83.  
  84. new FloodByPlayer[MAX_PLAYERS];
  85. new FloodTimer[MAX_PLAYERS];
  86.  
  87. forward FloodCheck(playerid);
  88. public FloodCheck(playerid)
  89. {
  90.     if(FloodByPlayer[playerid] >= MAX_FLOODLINES)
  91.     {
  92.         GameTextForPlayer(playerid, "~g~Dont Spam !", 3000, 3);
  93.     }
  94.     else FloodByPlayer[playerid] = 0;
  95.     return 1;
  96. }
  97. main()
  98. {
  99.     print("\n----------------------------------");
  100.     print(" Gangz Wars - Created By Avi");
  101.     print("----------------------------------\n");
  102. }
  103.  
  104. public OnGameModeInit()
  105. {
  106.     // Don't use these lines if it's a filterscript
  107.     SetGameModeText("Ganz Wars");
  108.     SetTimer("RandomMessages", 60000, true);
  109.     AddPlayerClass(105,2494.5027,-1683.7743,13.3385,18.2069,0,0,0,0,0,0); // Grove
  110.     AddPlayerClass(104,1929.0083,-1146.1027,25.1044,3.0105,0,0,0,0,0,0); // Ballas
  111.     return 1;
  112. }
  113.  
  114. public OnGameModeExit()
  115. {
  116.     return 1;
  117. }
  118.  
  119. public OnPlayerRequestClass(playerid, classid)
  120. {
  121.     SetPlayerPos(playerid,1588.5428,-1370.3191,330.0635);
  122.     SetPlayerCameraPos(playerid, 1558.5428,-1370.3191,330.0635);
  123.     SetPlayerCameraLookAt(playerid, 1558.5428,-1370.3191,330.0635);
  124.     switch(classid) // Switching between the classids
  125.     {
  126.          case 0:
  127.          {
  128.               SetPlayerTeam(playerid, Grove); // Setting players team
  129.               GameTextForPlayer(playerid, "~g~Grove Gang", 3000, 3); // Screen msg for player to show what team
  130.          }
  131.          case 1:
  132.          {
  133.               SetPlayerTeam(playerid, Ballas); // Same as above
  134.               GameTextForPlayer(playerid, "~r~Ballas Gang", 3000, 3); // Same as above
  135.          }
  136.     }
  137.     return 1;
  138. }
  139.  
  140. public OnPlayerConnect(playerid)
  141. {
  142.     new name[MAX_PLAYER_NAME]; //Making a new variable called 'name'. name[MAX_PLAYER_NAME] is created so we can use it to get player's name.
  143.     GetPlayerName(playerid,name,sizeof(name)); //Get player's name
  144.     if(fexist(Path(playerid))) /* Check if the connected user is registered or not. fexist stands for file exist. So if file exist in the files(Path(playerid)),*/
  145.     {// then
  146.         INI_ParseFile(Path(playerid),"loadaccount_user", .bExtra = true, .extra = playerid); //Will load user's data using INI_Parsefile.
  147.         ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_INPUT,"Login","Welcome back. This account is registered. \nInsert your password to login to your account","Login","Quit");/*A dialog with input style will appear so you can insert your password to login.*/
  148.     }
  149.     else //If the connected user is not registered,
  150.     {//then we will 'force' him to register :)
  151.         ShowPlayerDialog(playerid,dregister,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.","Register","Quit");
  152.         return 1;
  153.     }
  154.     FloodByPlayer[playerid] = 0;
  155.     FloodTimer[playerid] = SetTimerEx("FloodCheck",MAX_FLOOD_RATE_SECS,true,"i",playerid);
  156.     return 1;
  157. }
  158.  
  159. public OnPlayerDisconnect(playerid, reason)
  160. {
  161.     //Same as OnDialogResponse, we will save their stats inside of their user's account
  162.     if(fexist(Path(playerid)))//Will check if the file is exit or not inside of User's folder that we have created.
  163.     {
  164.         new INI:file = INI_Open(Path(playerid)); //will open their file
  165.         INI_SetTag(file,"Player's Data");//We will set a tag inside of user's account called "Player's Data"
  166.         INI_WriteInt(file,"AdminLevel",pInfo[playerid][Adminlevel]); //If you've set his/her admin level, then his/her admin level will be saved inside of his/her account
  167.         INI_WriteInt(file,"VIPLevel",pInfo[playerid][VIPlevel]);//As explained above
  168.         INI_WriteInt(file,"Money",GetPlayerMoney(playerid));//We will save his money inside of his account
  169.         INI_WriteInt(file,"Scores",GetPlayerScore(playerid));//We will save his score inside of his account
  170.         INI_WriteInt(file,"Kills",pInfo[playerid][Kills]);//As explained above
  171.         INI_WriteInt(file,"Deaths",pInfo[playerid][Deaths]);//As explained above
  172.         INI_Close(file);//Now after we've done saving their data, we now need to close the file
  173.         return 1;
  174.     }
  175.     FloodByPlayer[playerid] = 0;
  176.     KillTimer(FloodTimer[playerid]);
  177.     return 1;
  178. }
  179.  
  180. public OnPlayerSpawn(playerid)
  181. {
  182.     if(GetPlayerTeam(playerid) == Grove)
  183.     {
  184.         SetPlayerColor(playerid, GroveColor); // Set his color to CopsColor (BLUE)
  185.         GameTextForPlayer(playerid, "~g~Your Part of Grove Gang", 3000, 3);
  186.         SendClientMessage(playerid, GroveColor,"Your Part of Grove Gang ! Kill Other Gang Members");
  187.         SendClientMessage(playerid, BallasColor,"Type /help /cmds For Getting more Info About Server");
  188.         GivePlayerWeapon(playerid, 25, 500);
  189.         GivePlayerWeapon(playerid, 30, 500);
  190.         GivePlayerWeapon(playerid, 34, 500);
  191.     }
  192.     else if(GetPlayerTeam(playerid) == Ballas)
  193.     {
  194.         SetPlayerColor(playerid, BallasColor);  // Same as above but in this case, CriminalsColor (RED)
  195.         GameTextForPlayer(playerid, "~r~Your Part of Ballas Gang", 3000, 3);
  196.         SendClientMessage(playerid, BallasColor,"Your Part of Ballas Gang ! Kill Other Gang Members");
  197.         SendClientMessage(playerid, GroveColor,"Type /help /cmds For Getting more Info About Server");
  198.         GivePlayerWeapon(playerid, 25, 500);
  199.         GivePlayerWeapon(playerid, 30, 500);
  200.         GivePlayerWeapon(playerid, 34, 500);
  201.     }
  202.     return 1;
  203. }
  204.  
  205. public OnPlayerDeath(playerid, killerid, reason)
  206. {
  207.     pInfo[killerid][Kills]++;//Will give 1 kill to killer and it will be saved inside of his/her account
  208.     pInfo[playerid][Deaths]++;//Will give 1 death each time they die and it will be saved inside of his/her account
  209.     SendDeathMessage(killerid, playerid, reason); // Shows the kill in the killfeed/deathlog/death window
  210.     if(killerid != INVALID_PLAYER_ID)
  211.     {
  212.         SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
  213.         GivePlayerMoney(killerid, 5000);
  214.         GameTextForPlayer(killerid, "~W~Nice~Y~Shot !~n~~R~Got $5000 & 1 Score", 3000, 1); // Same as above
  215.     }
  216.     return 1;
  217. }
  218.  
  219. public OnVehicleSpawn(vehicleid)
  220. {
  221.     return 1;
  222. }
  223.  
  224. public OnVehicleDeath(vehicleid, killerid)
  225. {
  226.     return 1;
  227. }
  228.  
  229. public OnPlayerText(playerid, text[])
  230. {
  231.     if(text[0] == '+') // : can be changed to whatever symbol u wanna use for player to enable the teamchat.
  232.     {
  233.         new string[128];  GetPlayerName(playerid, string, sizeof(string)); // Making the new's
  234.         format(string, sizeof(string), "[Gang Chat] %s: %s", string, text[1]); // Formatted the message
  235.         printf("%s", string); // Printed it BOTH ingame + the server log
  236.  
  237.         for(new i = 0; i < MAX_PLAYERS; i++) // Getting the player team and color, required for formatting the msg.
  238.         {
  239.             if(IsPlayerConnected(i) && GetPlayerTeam(i) == GetPlayerTeam(playerid)) SendClientMessage(i, GetPlayerColor(playerid), string);
  240.         }
  241.         return 0;
  242.     }
  243.     FloodByPlayer[playerid] = FloodByPlayer[playerid] +1;
  244.     return 1;
  245. }
  246.  
  247. public OnPlayerCommandText(playerid, cmdtext[])
  248. {
  249.     if (strcmp("/help", cmdtext, true, 10) == 0)
  250.     {
  251.         ShowPlayerDialog(playerid, DIALOG_HELP, DIALOG_STYLE_LIST, "Gangs Help", "{00FF00}Grove Gang\n{FF0000}Ballas Gang\nOthers", "Select", "Cancel");
  252.         return 1;
  253.     }
  254.     if (strcmp("/rules", cmdtext, true, 10) == 0)
  255.     {
  256.         ShowPlayerDialog(playerid, DIALOG_RULES, DIALOG_STYLE_LIST, "Rules", "Dont Teamkill\nRespect Admins and Other Players\nDont Ask to Be Admin ! Asking Always Decrease your Chances !\n\n{ffff00}In The Last, Enjoy Our Server", "Accept", "Decline");
  257.         return 1;
  258.     }
  259.     if (strcmp("/cmds", cmdtext, true, 10) == 0)
  260.     {
  261.         ShowPlayerDialog(playerid, DIALOG_CMDS, DIALOG_STYLE_LIST, "Server Commands", "{ff0000}/rules - {ffffff}To See Server Rules\n{ff0000}/kill - {ffffff}To Kill Your Self !\n{ff0000}\n{ff0000}/changegang - {ffffff}To Change Your Gang", "Select", "Cancel");
  262.         return 1;
  263.     }
  264.     if (strcmp("/kill", cmdtext, true, 10) == 0)
  265.     {
  266.         SetPlayerHealth(playerid, 0.0);
  267.         SendClientMessage(playerid, BallasColor,"You Have Suicide !");
  268.         return 1;
  269.     }
  270.     if (strcmp("/changegang", cmdtext, true, 10) == 0)
  271.     {
  272.         SetPlayerHealth(playerid, 0.0);
  273.         ForceClassSelection(playerid);
  274.         return 1;
  275.     }
  276.     return 0;
  277. }
  278.  
  279. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  280. {
  281.     return 1;
  282. }
  283.  
  284. public OnPlayerExitVehicle(playerid, vehicleid)
  285. {
  286.     return 1;
  287. }
  288.  
  289. public OnPlayerStateChange(playerid, newstate, oldstate)
  290. {
  291.     return 1;
  292. }
  293.  
  294. public OnPlayerEnterCheckpoint(playerid)
  295. {
  296.     return 1;
  297. }
  298.  
  299. public OnPlayerLeaveCheckpoint(playerid)
  300. {
  301.     return 1;
  302. }
  303.  
  304. public OnPlayerEnterRaceCheckpoint(playerid)
  305. {
  306.     return 1;
  307. }
  308.  
  309. public OnPlayerLeaveRaceCheckpoint(playerid)
  310. {
  311.     return 1;
  312. }
  313.  
  314. public OnRconCommand(cmd[])
  315. {
  316.     return 1;
  317. }
  318.  
  319. public OnPlayerRequestSpawn(playerid)
  320. {
  321.     return 1;
  322. }
  323.  
  324. public OnObjectMoved(objectid)
  325. {
  326.     return 1;
  327. }
  328.  
  329. public OnPlayerObjectMoved(playerid, objectid)
  330. {
  331.     return 1;
  332. }
  333.  
  334. public OnPlayerPickUpPickup(playerid, pickupid)
  335. {
  336.     return 1;
  337. }
  338.  
  339. public OnVehicleMod(playerid, vehicleid, componentid)
  340. {
  341.     return 1;
  342. }
  343.  
  344. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  345. {
  346.     return 1;
  347. }
  348.  
  349. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  350. {
  351.     return 1;
  352. }
  353.  
  354. public OnPlayerSelectedMenuRow(playerid, row)
  355. {
  356.     return 1;
  357. }
  358.  
  359. public OnPlayerExitedMenu(playerid)
  360. {
  361.     return 1;
  362. }
  363.  
  364. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  365. {
  366.     return 1;
  367. }
  368.  
  369. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  370. {
  371.     return 1;
  372. }
  373.  
  374. public OnRconLoginAttempt(ip[], password[], success)
  375. {
  376.     return 1;
  377. }
  378.  
  379. public OnPlayerUpdate(playerid)
  380. {
  381.     return 1;
  382. }
  383.  
  384. public OnPlayerStreamIn(playerid, forplayerid)
  385. {
  386.     return 1;
  387. }
  388.  
  389. public OnPlayerStreamOut(playerid, forplayerid)
  390. {
  391.     return 1;
  392. }
  393.  
  394. public OnVehicleStreamIn(vehicleid, forplayerid)
  395. {
  396.     return 1;
  397. }
  398.  
  399. public OnVehicleStreamOut(vehicleid, forplayerid)
  400. {
  401.     return 1;
  402. }
  403.  
  404. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  405. {
  406.     if(dialogid == dregister) //If dialog id is a register dialog
  407.     {//then
  408.         if(!response) return Kick(playerid); //If they clicked the second button "Quit", we will kick them.
  409.         if(response) //if they clicked the first button "Register"
  410.         {//then
  411.             if(!strlen(inputtext)) //If they didn't enter any password
  412.             {// then we will tell to them to enter the password to register
  413.                 ShowPlayerDialog(playerid,dregister,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.\nPlease enter the password!","Register","Quit");
  414.                 return 1;
  415.             }
  416.             //If they have entered a correct password for his/her account...
  417.             new hashpass[129]; //Now we will create a new variable to hash his/her password
  418.             WP_Hash(hashpass,sizeof(hashpass),inputtext);//We will use whirlpool to hash their inputted text
  419.             new INI:file = INI_Open(Path(playerid)); // we will open a new file for them to save their account inside of Scriptfiles/Users folder
  420.             INI_SetTag(file,"Player's Data");//We will set a tag inside of user's account called "Player's Data"
  421.             INI_WriteString(file,"Password",hashpass);//This will write a hashed password into user's account
  422.             INI_WriteInt(file,"AdminLevel",0); //Write an integer inside of user's account called "AdminLevel". We will set his level to 0 after he registered.
  423.             INI_WriteInt(file,"VIPLevel",0);//As explained above
  424.             INI_WriteInt(file,"Money",0);//Write an integer inside of user's account called "Money". We will set their money to 0 after he registered
  425.             INI_WriteInt(file,"Scores",0);//Write an integer inside of user's account called "Scores". We will set their score to 0 after he registered
  426.             INI_WriteInt(file,"Kills",0);//As explained above
  427.             INI_WriteInt(file,"Deaths",0);//As explained above
  428.             INI_Close(file);//Now after we've done saving their data, we now need to close the file
  429.             SendClientMessage(playerid,-1,"You have been successfully registered");//Tell to them that they have successfully registered a new account
  430.             return 1;
  431.         }
  432.     }
  433.     if(dialogid == dlogin) //If dialog id is a login dialog
  434.     {//then
  435.         if(!response) return Kick(playerid); //If they clicked the second button "Quit", we will kick them.
  436.         if(response) //if they clicked the first button "Register"
  437.         {//then
  438.             new hashpass[129]; //Will create a new variable to hash his/her password
  439.             WP_Hash(hashpass,sizeof(hashpass),inputtext); //Will hash inputted password
  440.             if(!strcmp(hashpass,pInfo[playerid][Pass])) //If they have insert their correct password
  441.             {//then
  442.                 INI_ParseFile(Path(playerid),"loadaccount_user",.bExtra = true, .extra = playerid);//We will load his account's data from user's path
  443.                 SetPlayerScore(playerid,pInfo[playerid][Scores]);//We will get their score inside of his user's account and we will set it here
  444.                 GivePlayerMoney(playerid,pInfo[playerid][Money]);//As explained above
  445.                 SendClientMessage(playerid,-1,"Welcome back! You have successfully logged in");//Tell them that they've successfully logged in
  446.             }
  447.             else //If they've entered an incorrect password
  448.             {//then
  449.                 ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_INPUT,"Login","Welcome back. This account is registered. \nInsert your password to login to your account.\nIncorrect password!","Login","Quit");//We will tell to them that they've entered an incorrect password
  450.                 return 1;
  451.             }
  452.         }
  453.     }
  454.     if(dialogid == DIALOG_HELP)
  455.     {
  456.         if(response) // If they clicked 'Select' or double-clicked a weapon
  457.         {
  458.             // Give them the weapon
  459.             if(listitem == 0) // They selected the first item - Desert Eagle
  460.             {
  461.                  ShowPlayerDialog(playerid,DIALOG_GHELP,DIALOG_STYLE_MSGBOX,"Grove Help","Grove Gang is a Gang Which Include all Server Common Members\nIts a Good Gang and its color is Green !\n + To Gang Chat","Close","Cancel");
  462.             }
  463.             if(listitem == 1) // They selected the second item - AK-47
  464.             {
  465.                 ShowPlayerDialog(playerid,DIALOG_BHELP,DIALOG_STYLE_MSGBOX,"Ballas Help","Ballas Gang is a Gang Which Include all Server Common Members\nIts a Good Gang and its color is Pink !\n + To Gang Chat","Close","Cancel");
  466.             }
  467.             if(listitem == 2) // They selected the third item - Desert Eagle
  468.             {
  469.                 ShowPlayerDialog(playerid,DIALOG_OHELP,DIALOG_STYLE_MSGBOX,"Other","{00ff00}Server Commands\n\n{ff0000}/rules - {ffffff}To See Server Rules\n{ff0000}/cmds - {ffffff}To See Server all Commands\n\n{ff00ff}For More Help, Contact {ffffff}Avi","Close","Cancel");
  470.             }
  471.         }
  472.         return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
  473.     }
  474.     return 1;
  475. }
  476.  
  477. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  478. {
  479.     return 1;
  480. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement