Y_Less

YSI_City_Selection.pwn

Mar 26th, 2011
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.99 KB | None | 0 0
  1. // This MUST go ABOVE "#include <YSI>"
  2. //#define FILTERSCRIPT
  3.  
  4. #include <YSI\y_classes>
  5. #include <YSI\y_commands>
  6. #include <YSI\y_groups>
  7.  
  8. main()
  9. {
  10.     print("\n----------------------------------");
  11.     print(" Advanced class selection example");
  12.     print("----------------------------------\n");
  13. }
  14.  
  15. new
  16.     // City groups
  17.     Group:gGroupNC,
  18.     Group:gGroupLS,
  19.     Group:gGroupLV,
  20.     Group:gGroupSF,
  21.     // Fake admin group
  22.     Group:gGroupAdmin;
  23.  
  24. // Kill yourself
  25. YCMD:kill(playerid, params[], help)
  26. {
  27.     #pragma unused params
  28.     if (help)
  29.     {
  30.         // Player typed "/help kill"
  31.     }
  32.     else
  33.     {
  34.         // Player typed "/kill"
  35.         SetPlayerHealth(playerid, 0.0);
  36.     }
  37.     return 1;
  38. }
  39.  
  40. // Fake Login, used in place of an admin system
  41. YCMD:fl(playerid, params[], help)
  42. {
  43.     #pragma unused params
  44.     if (help)
  45.     {
  46.         // Player typed "/help fl"
  47.     }
  48.     else
  49.     {
  50.         // Player typed "/fl"
  51.         Group_SetPlayer(gGroupAdmin, playerid, true);
  52.     }
  53.     return 1;
  54. }
  55.  
  56. public OnGameModeInit()
  57. {
  58.     //  Group setup
  59.     // =============
  60.    
  61.     // Create the groups to use in class selection
  62.     gGroupNC = Group_Create("No City"); // No city
  63.     gGroupLV = Group_Create("Las Venturas"); // Las Venturas
  64.     gGroupLS = Group_Create("Los Santos"); // Los Santos
  65.     gGroupSF = Group_Create("San Fierro"); // San Fierro
  66.    
  67.     // Create the group that our "admins" go in (to become an admin type "/fl")
  68.     gGroupAdmin = Group_Create("Admin");
  69.    
  70.     //  City selection
  71.     // ================
  72.    
  73.     // These classes are added "for" the "No City" group and "as" one of the
  74.     // other groups.  This means that people in the "No City" group can see the
  75.     // class and can select them to be put in one of the other groups
  76.     Class_AddEx(gGroupNC, gGroupLV, 0, 0.0, 0.0, 0.0, 0.0);
  77.     Class_AddEx(gGroupNC, gGroupLS, 0, 0.0, 0.0, 0.0, 0.0);
  78.     Class_AddEx(gGroupNC, gGroupSF, 0, 0.0, 0.0, 0.0, 0.0);
  79.    
  80.     //  Skin selection
  81.     // ================
  82.    
  83.     // Las Venturas skins
  84.    
  85.     // Only people in the LV group can see these skins (location borrowed from
  86.     // LVDM)
  87.     // Spawns with no weapons
  88.     Class_AddForGroup(gGroupLV, 171, 2150.0186, 2734.2297, 11.1763, 0.0);
  89.     // Spawns with 1 weapon
  90.     Class_AddForGroup(gGroupLV, 83,  2150.0186, 2734.2297, 11.1763, 0.0, WEAPON_COLT45, 100);
  91.     // Spawns with armour
  92.     Class_AddForGroup(gGroupLV, 172, 2150.0186, 2734.2297, 11.1763, 0.0, WEAPON_ARMOUR, 100);
  93.    
  94.     // Los Santos skins.
  95.    
  96.     // Only people in the LS group can see these skins
  97.     // Spawns with 3 weapons
  98.     Class_AddForGroup(gGroupLS, 106, 667.0339, -1275.7842, 13.4609, 0.0, WEAPON_COLT45, 100, WEAPON_SAWEDOFF, 20, WEAPON_MINIGUN, 1000);
  99.     // Spawns with 4 weapons
  100.     Class_AddForGroup(gGroupLS, 104, 667.0339, -1275.7842, 13.4609, 0.0, WEAPON_COLT45, 100, WEAPON_SAWEDOFF, 20, WEAPON_MINIGUN, 1000, WEAPON_M4, 300);
  101.     // Spawns with 7 weapons
  102.     Class_AddForGroup(gGroupLS, 115, 667.0339, -1275.7842, 13.4609, 0.0, WEAPON_COLT45, 100, WEAPON_SAWEDOFF, 20, WEAPON_MINIGUN, 1000, WEAPON_M4, 300, WEAPON_UZI, 150, WEAPON_SNIPER, 10, WEAPON_FIREEXTINGUISHER, 5);
  103.    
  104.     // San Fierro skins
  105.    
  106.     // Only people in the SF group can see these skins (location borrowed from
  107.     // SFTDM).
  108.     // Spawns with 4 weapons and armour
  109.     Class_AddForGroup(gGroupSF, 260, -2062.5583, 237.4662, 35.7149, 0.0, WEAPON_COLT45, 100, WEAPON_SAWEDOFF, 20, WEAPON_MINIGUN, 1000, WEAPON_M4, 300, WEAPON_ARMOUR, 100);
  110.     // Spawns with 1 weapon and armour
  111.     Class_AddForGroup(gGroupSF, 249, -2062.5583, 237.4662, 35.7149, 0.0, WEAPON_COLT45, 100, WEAPON_ARMOUR, 100);
  112.     // Spawns with no weapons
  113.     Class_AddForGroup(gGroupSF, 259, -2062.5583, 237.4662, 35.7149, 0.0);
  114.    
  115.     // Admin skin
  116.    
  117.     // This skin can be selected only be anyone who has previously typed "/fl"
  118.     // This skin is always visible (wether in city or skin selection)
  119.     Class_AddForGroup(gGroupAdmin, 217, 1958.0, 1343.0, 15.0, 269.0);
  120.    
  121.     // End
  122.     return 1;
  123. }
  124.  
  125. public OnPlayerRequestClass(playerid, classid)
  126. {
  127.     switch (classid)
  128.     {
  129.         case 0:
  130.         {
  131.             // Las Venturas
  132.             SetPlayerInterior(playerid, 0);
  133.             SetPlayerPos(playerid, 258.4893, -41.4008, 1002.0234);
  134.             SetPlayerCameraPos(playerid, 947.2557, 2586.8577, 17.2663);
  135.             SetPlayerCameraLookAt(playerid, 959.7480, 2577.1262, 23.2179);
  136.         }
  137.         case 1:
  138.         {
  139.             // Los Santos
  140.             SetPlayerInterior(playerid, 0);
  141.             SetPlayerPos(playerid, 1414.0569, -879.7341, 70.3589);
  142.             SetPlayerCameraPos(playerid, 1414.0569, -879.7341, 71.3589);
  143.             SetPlayerCameraLookAt(playerid, 1415.6584, -821.6124, 76.4726);
  144.         }
  145.         case 2:
  146.         {
  147.             // San Fierro
  148.             SetPlayerInterior(playerid, 0);
  149.             SetPlayerPos(playerid, -1786.5815, -575.8611, 16.8192);
  150.             SetPlayerCameraPos(playerid, -1786.5815, -575.8611, 16.8192);
  151.             SetPlayerCameraLookAt(playerid, -1767.5608, -575.3600, 26.9292);
  152.         }
  153.         default:
  154.         {
  155.             // Skin
  156.             // Borrowed from LVDM
  157.             SetPlayerInterior(playerid, 14);
  158.             SetPlayerPos(playerid, 258.4893, -41.4008, 1002.0234);
  159.             SetPlayerFacingAngle(playerid, 270.0);
  160.             SetPlayerCameraPos(playerid, 256.0815, -43.0475, 1004.0234);
  161.             SetPlayerCameraLookAt(playerid, 258.4893, -41.4008, 1002.0234);
  162.         }
  163.     }
  164.     return 1;
  165. }
  166.  
  167. public OnPlayerRequestSpawnEx(playerid, classid) // Added extra
  168. {
  169.     // return 0 - Don't allow the spawn
  170.     // return 1 - Allow the spawn
  171.     // return -1 - Don't allow the spawn and re-process the current class
  172.    
  173.     // -1 is used here to show a different skin as they've selected a city
  174.     // thus their group has changed, thus their current skin selection
  175.     // options have changed
  176.     if (classid < 3)
  177.     {
  178.         // City selection
  179.         // Remove from the no city group
  180.         Group_SetPlayer(gGroupNC, playerid, false);
  181.         // Redo selection with new groups
  182.         return -1;
  183.     }
  184.     return 1;
  185. }
  186.  
  187. public OnPlayerConnect(playerid)
  188. {
  189.     // Add them to the no city group as they don't have a city yet
  190.     Group_SetPlayer(gGroupNC, playerid, true);
  191.     return 1;
  192. }
  193.  
  194. public OnPlayerSpawn(playerid)
  195. {
  196.     // Reset the groups
  197.     Group_SetPlayer(gGroupNC, playerid, true);
  198.     Group_SetPlayer(gGroupLS, playerid, false);
  199.     Group_SetPlayer(gGroupLV, playerid, false);
  200.     Group_SetPlayer(gGroupSF, playerid, false);
  201.    
  202.     // Reset the interior
  203.     SetPlayerInterior(playerid, 0);
  204.     return 1;
  205. }
Advertisement
Add Comment
Please, Sign In to add comment