Advertisement
Y_Less

YSI_City_Selection.pwn

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