1
0

family_levels.inc 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. ______ _ _ _ _ ____ _____ _
  3. | ____| (_) | | | | | | _ \ | __ \ | |
  4. | |__ __ _ _ __ ___ _| |_ _ | | _____ _____| |___ | |_) |_ _ | | | | ___ ___ _ __ ___ ___ _ __ __| |
  5. | __/ _` | '_ ` _ \| | | | | | | | / _ \ \ / / _ \ / __| | _ <| | | | | | | |/ _ \/ __| '_ ` _ \ / _ \| '_ \ / _` |
  6. | | | (_| | | | | | | | | |_| | | |___| __/\ V / __/ \__ \ | |_) | |_| | | |__| | __/\__ \ | | | | | (_) | | | | (_| |
  7. |_| \__,_|_| |_| |_|_|_|\__, | |______\___| \_/ \___|_|___/ |____/ \__, | |_____/ \___||___/_| |_| |_|\___/|_| |_|\__,_|
  8. __/ | __/ |
  9. |___/ |___/
  10. http://www.gta-sarp.com/forums/showthread.php?298108
  11. Read post:
  12. http://www.gta-sarp.com/forums/showthread.php?298108-Family-system&p=2169479&viewfull=1#post2169479
  13. Families get XP by activity, roleplay and shootouts activities.
  14. 1. Roleplay - /famrp - RP given by gang mods
  15. 2. Activity - if you have 5+ members in your family online, on /signcheck you get XP
  16. 3. Shootouts - get XP for making a successful bank robbery
  17. 8-10 levels
  18. */
  19. GetFamilyLevel(familyid) // simply check what level the family is, as it's based on XP
  20. {
  21. new xp = FamilyInfo[familyid][fXP];
  22. switch(xp)
  23. {
  24. case 0..49: return 1;
  25. case 50..149: return 2;
  26. case 150..299: return 3;
  27. case 300..499: return 4;
  28. case 500..749: return 5;
  29. case 750..1049: return 6;
  30. case 1050..1399: return 7;
  31. case 1400..1799: return 8;
  32. }
  33. if(xp >= 1799) return 8;
  34. return 1;
  35. }
  36. GetFamilyNextXP(familyid) // couldn't think of a better name. This function returns the amount of XP the family needs to level up
  37. {
  38. new xp = FamilyInfo[familyid][fXP];
  39. switch(xp)
  40. {
  41. case 0..49: return 50;
  42. case 50..149: return 150;
  43. case 150..299: return 300;
  44. case 300..499: return 500;
  45. case 500..749: return 750;
  46. case 750..1049: return 1050;
  47. case 1050..1399: return 1400;
  48. case 1400..1799: return 1800;
  49. }
  50. if(xp >= 1799) return -1;
  51. return 1;
  52. }
  53. GrantFamXP(family, amount)
  54. {
  55. new xp = FamilyInfo[family][fXP];
  56. new nextxp = GetFamilyNextXP(family);
  57. if(xp+amount > nextxp) // if family leveled up
  58. {
  59. if(GetFamilyLevel(family) == 8) return 1; // max level
  60. FamilyInfo[family][fXP] += amount;
  61. new msgstr[50];
  62. format(msgstr, sizeof(msgstr), "Your family has leveled up! New level: %d", GetFamilyLevel(family));
  63. foreach(new i: Player)
  64. {
  65. if(PlayerInfo[i][pFMember] == family)
  66. {
  67. SendClientMessage(i, COLOR_LIGHTBLUE, msgstr);
  68. }
  69. }
  70. }
  71. else FamilyInfo[family][fXP] += amount;
  72. SaveFamilies();
  73. return 1;
  74. }