Advertisement
ZumeZero

zRaces - Gamemode test

Jan 23rd, 2015
483
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 10.68 KB | None | 0 0
  1. // This is a comment
  2. // uncomment the line below if you want to write a filterscript
  3. //#define FILTERSCRIPT
  4.  
  5. #include <a_samp>
  6. #include <zcmd>
  7. #include <sscanf2>
  8. #include <a_mysql>
  9. #include <zRace>
  10. #include <foreach>
  11.  
  12. static stock g_arrVehicleNames[][] = {
  13.     "Landstalker", "Bravura", "Buffalo", "Linerunner", "Perrenial", "Sentinel", "Dumper", "Firetruck", "Trashmaster",
  14.     "Stretch", "Manana", "Infernus", "Voodoo", "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam",
  15.     "Esperanto", "Taxi", "Washington", "Bobcat", "Whoopee", "BF Injection", "Hunter", "Premier", "Enforcer",
  16.     "Securicar", "Banshee", "Predator", "Bus", "Rhino", "Barracks", "Hotknife", "Trailer", "Previon", "Coach",
  17.     "Cabbie", "Stallion", "Rumpo", "RC Bandit", "Romero", "Packer", "Monster", "Admiral", "Squalo", "Seasparrow",
  18.     "Pizzaboy", "Tram", "Trailer", "Turismo", "Speeder", "Reefer", "Tropic", "Flatbed", "Yankee", "Caddy", "Solair",
  19.     "Berkley's RC Van", "Skimmer", "PCJ-600", "Faggio", "Freeway", "RC Baron", "RC Raider", "Glendale", "Oceanic",
  20.     "Sanchez", "Sparrow", "Patriot", "Quad", "Coastguard", "Dinghy", "Hermes", "Sabre", "Rustler", "ZR-350", "Walton",
  21.     "Regina", "Comet", "BMX", "Burrito", "Camper", "Marquis", "Baggage", "Dozer", "Maverick", "News Chopper", "Rancher",
  22.     "FBI Rancher", "Virgo", "Greenwood", "Jetmax", "Hotring", "Sandking", "Blista Compact", "Police Maverick",
  23.     "Boxville", "Benson", "Mesa", "RC Goblin", "Hotring Racer A", "Hotring Racer B", "Bloodring Banger", "Rancher",
  24.     "Super GT", "Elegant", "Journey", "Bike", "Mountain Bike", "Beagle", "Cropduster", "Stunt", "Tanker", "Roadtrain",
  25.     "Nebula", "Majestic", "Buccaneer", "Shamal", "Hydra", "FCR-900", "NRG-500", "HPV1000", "Cement Truck", "Tow Truck",
  26.     "Fortune", "Cadrona", "SWAT Truck", "Willard", "Forklift", "Tractor", "Combine", "Feltzer", "Remington", "Slamvan",
  27.     "Blade", "Streak", "Freight", "Vortex", "Vincent", "Bullet", "Clover", "Sadler", "Firetruck", "Hustler", "Intruder",
  28.     "Primo", "Cargobob", "Tampa", "Sunrise", "Merit", "Utility", "Nevada", "Yosemite", "Windsor", "Monster", "Monster",
  29.     "Uranus", "Jester", "Sultan", "Stratum", "Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma", "Savanna", "Bandito",
  30.     "Freight Flat", "Streak Carriage", "Kart", "Mower", "Dune", "Sweeper", "Broadway", "Tornado", "AT-400", "DFT-30",
  31.     "Huntley", "Stafford", "BF-400", "News Van", "Tug", "Trailer", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club",
  32.     "Freight Box", "Trailer", "Andromada", "Dodo", "RC Cam", "Launch", "LSPD Car", "SFPD Car", "LVPD Car",
  33.     "Police Rancher", "Picador", "S.W.A.T", "Alpha", "Phoenix", "Glendale", "Sadler", "Luggage", "Luggage", "Stairs",
  34.     "Boxville", "Tiller", "Utility Trailer"
  35. };
  36.  
  37.  
  38. main()
  39. {
  40.     print("\n----------------------------------");
  41.     print(" Blank Gamemode by your name here");
  42.     print("----------------------------------\n");
  43.  
  44.  
  45. }
  46. public OnPlayerSpawn(playerid)
  47. {
  48.     for (new i = 0; i != MAX_PLAYER_ATTACHED_OBJECTS; i ++) {
  49.             RemoveAttachedObject(playerid, i);
  50.     }
  51.     SetTimerEx("AddPlayerToys", 3000, false, "i", playerid);
  52.     return 1;
  53. }
  54.  
  55. stock RemoveAttachedObject(playerid, slot)
  56. {
  57.     if (!IsPlayerConnected(playerid))
  58.         return 0;
  59.  
  60.     if(!IsPlayerAttachedObjectSlotUsed(playerid, slot))
  61.         return 0;
  62.  
  63.     RemovePlayerAttachedObject(playerid, slot);
  64.     return 1;
  65. }
  66.  
  67. forward AddPlayerToys(playerid); public AddPlayerToys(playerid)
  68. {
  69.     if(playerid == INVALID_PLAYER_ID)
  70.         return 0;
  71.  
  72.     if(!IsPlayerConnected(playerid))
  73.         return 0;
  74.  
  75.     SetPlayerAttachedObject(playerid,9,1310,1,-0.054000,-0.155999,-0.016999,0.000000,89.300018,0.000000,1.000000,1.000000,1.000000);
  76.     return 1;
  77. }
  78.  
  79. public OnGameModeInit()
  80. {
  81.     // Don't use these lines if it's a filterscript
  82.     SetGameModeText("Race Mode");
  83.     SetWorldTime(21);
  84.     SetWeather(10);
  85.     AllowInteriorWeapons(true);
  86.     EnableStuntBonusForAll(true);
  87.  
  88.     AddPlayerClass(284, 354.7566,-84.7419,1.3355,169.4997, 0, 0, 0, 0, 0, 0);
  89.     CreateVehicle(552, 336.6826, -77.2777, 1.1614, 19.2302, -1, -1, 60000);
  90.     CreateVehicle(552, 318.5034, -77.0695, 1.1998, 92.6342, -1, -1, 60000);
  91.     CreateVehicle(552, 327.6026, -108.5993, 1.1948, 176.2344, -1, -1, 60000);
  92.     CreateVehicle(552, 338.1276, -112.6025, 1.1050, 349.6361, -1, -1, 60000);
  93.     CreateVehicle(400, 320.0182, -87.7260, 2.1224, 89.1613, -1, -1, 60000);
  94.     return 1;
  95. }
  96.  
  97. CMD:createrace(playerid, params[])
  98. {
  99.     new Float:x,
  100.         Float:y,
  101.         Float:z,
  102.         Float:r,
  103.         id = -1;
  104.  
  105.     GetPlayerPos(playerid, x,y,z);
  106.     GetPlayerFacingAngle(playerid, r);
  107.  
  108.     id = CreateRace(x,y,z, GetPlayerInterior(playerid), GetPlayerVirtualWorld(playerid));
  109.     if(id != -1)
  110.     {
  111.         SetRaceFacingAngle(id, r);
  112.         SendClientMessageEx(playerid, -1, "Creaste la carrera n-%d", id);
  113.     }
  114.     return 1;
  115. }
  116.  
  117. CMD:carcreate(playerid, params[])
  118. {
  119.     new carmodel[32];
  120.     if(sscanf(params, "s[32]", carmodel))
  121.         return 1;
  122.  
  123.     if ((carmodel[0] = GetVehicleModelByName(carmodel)) == 0)
  124.         return SendClientMessage(playerid, -1, "Modelo invalido.");
  125.  
  126.     static Float:pPos[4];
  127.     GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
  128.     GetPlayerFacingAngle(playerid, pPos[3]);
  129.     new id = CreateVehicle(carmodel[0], pPos[0], pPos[1], pPos[2], pPos[3], -1, -1, 0);
  130.     PutPlayerInVehicle(playerid, id, 0);
  131.     return 1;
  132.  
  133.  
  134. }
  135.  
  136. CMD:carsave(playerid, params[])
  137. {
  138.     if(!IsPlayerInAnyVehicle(playerid))
  139.         return 0;
  140.  
  141.     new id = GetPlayerVehicleID(playerid);
  142.     if(id == INVALID_VEHICLE_ID)
  143.         return 0;
  144.  
  145.     static Float:pPos[4];
  146.     GetVehiclePos(id, pPos[0], pPos[1], pPos[2]);
  147.     GetVehicleZAngle(id, pPos[3]);
  148.     printf("CreateVehicle(%d, %.4f, %.4f, %.4f, %.4f, -1, -1, 60000);", GetVehicleModel(id), pPos[0], pPos[1], pPos[2], pPos[3]);
  149.     SendClientMessageEx(playerid, -1, "*Vehicle %d saved! (logs)", id);
  150.     return 1;
  151. }
  152.  
  153.  
  154. public OnPlayerFinishRace(playerid, raceid){
  155.     SendClientMessageEx(playerid, -1, "Finalizado!");
  156. }
  157.  
  158. GetVehicleModelByName(const name[])
  159. {
  160.     if (IsNumeric(name) && (strval(name) >= 400 && strval(name) <= 611))
  161.         return strval(name);
  162.  
  163.     for (new i = 0; i < sizeof(g_arrVehicleNames); i ++)
  164.     {
  165.         if (strfind(g_arrVehicleNames[i], name, true) != -1)
  166.         {
  167.             return i + 400;
  168.         }
  169.     }
  170.     return 0;
  171. }
  172.  
  173.  
  174. IsNumeric(const str[])
  175. {
  176.     for (new i = 0, l = strlen(str); i != l; i ++)
  177.     {
  178.         if (i == 0 && str[0] == '-')
  179.             continue;
  180.  
  181.         else if (str[i] < '0' || str[i] > '9')
  182.             return 0;
  183.     }
  184.     return 1;
  185. }
  186.  
  187. CMD:startrace(playerid, params[])
  188. {
  189.     if(sscanf(params, "d", params[0]))
  190.         return 1;
  191.  
  192.     if(!RaceExist(params[0]))
  193.         return 0;
  194.  
  195.     new
  196.         c = TrackCountOfRace(params[0]);
  197.  
  198.     if(c < 3)
  199.         return SendClientMessage(playerid, -1, "Esa carrera no tiene mas de 3 tracks");
  200.  
  201.     new
  202.         str[64];
  203.  
  204.     foreach(new i : Player)
  205.     {
  206.         StartRace(i, params[0]);
  207.     }
  208.     format(str, sizeof(str), "* La carrera %d ha iniciado!", params[0]);
  209.     SendClientMessageToAll(-1, str);
  210.     return 1;
  211. }
  212.  
  213.  
  214.  
  215. CMD:editrace(playerid, params[])
  216. {
  217.     enum ColorsEnum{
  218.         color_id,
  219.         message[34],
  220.     };
  221.     new
  222.         Colors[][ColorsEnum] = {
  223.             {0xC00000FF, "* /editrace [raceid] [type]"}, // red
  224.             {0x66CC00FF} // lime
  225.         }, raceid, type[24], string[128];
  226.  
  227.     if(sscanf(params, "is[24]S()[128]", raceid, type, string))
  228.     {
  229.         new active = GetActiveRaces();
  230.         SendClientMessage(playerid, Colors[0][color_id], Colors[0][message]);
  231.         if(active > 0)
  232.             SendClientMessageEx(playerid, -1, "Carreras disponibles: %s", StrAvailableRaces());
  233.        
  234.         SendClientMessage(playerid, -1, "Tipos: StartPos - GO - CreateTrack - SetTrack - ");
  235.         return 1;
  236.     }
  237.     else{
  238.         if (!RaceExist(raceid))
  239.             return 0;
  240.  
  241.         if (!strcmp(type, "startpos", true)){
  242.             //if (sscanf(string, "d", raceid))
  243.                 //return SendClientMessage(playerid, Colors[0][color_id], Colors[0][message]);
  244.             static
  245.                 Float:pPos[4];
  246.             GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
  247.             GetPlayerFacingAngle(playerid, pPos[3]);
  248.             SetRacePos(raceid, pPos[0], pPos[1], pPos[2]);
  249.             SetRaceFacingAngle(raceid, pPos[3]);
  250.             SetRaceVirtualWorld(raceid, GetPlayerVirtualWorld(playerid));
  251.             SetRaceInterior(raceid, GetPlayerInterior(playerid));
  252.             UpdateRaceDatabaseAll(raceid);
  253.  
  254.             SendClientMessageEx(playerid, -1,"* Sustituiste la posicion de inicio de la carrera %d,", raceid);
  255.         }
  256.         else if(!strcmp(type, "GO", true))
  257.         {
  258.             static
  259.                 Float:pPos[4];
  260.  
  261.             GetRacePos(raceid, pPos[0], pPos[1], pPos[2]);
  262.             GetRaceFacingAngle(raceid, pPos[3]);
  263.             SetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
  264.             SetPlayerFacingAngle(playerid, pPos[3]);
  265.             SetPlayerVirtualWorld(playerid, GetRaceVirtualWorld(raceid));
  266.             SetPlayerInterior(playerid, GetRaceInterior(raceid));
  267.  
  268.             SendClientMessageEx(playerid, -1,"* Fuiste teleportado a la carrera %d,", raceid);
  269.  
  270.         }
  271.         else if(!strcmp(type, "createtrack", true))
  272.         {
  273.             static
  274.                 Float:pPos[3];
  275.             GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
  276.  
  277.             new id = -1;
  278.             id = CreateTrack(raceid, pPos[0], pPos[1], pPos[2]);
  279.  
  280.             SendClientMessageEx(playerid, -1,"* Create una track a la race %d. (Track %d)", raceid, id);
  281.         }
  282.         else if(!strcmp(type, "settrack", true))
  283.         {
  284.             new track;
  285.             if (sscanf(string, "d", track))
  286.                 return 1;
  287.  
  288.             if(TrackExist(raceid, track))
  289.                 return 0;
  290.  
  291.             static
  292.                 Float:pPos[3];
  293.             GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
  294.             SetTrackPos(raceid, track, pPos[0], pPos[1], pPos[2]);
  295.             SendClientMessageEx(playerid, -1,"* Editaste la posicion del track %d (Race %d),", track, raceid);
  296.         }
  297.     }
  298.     return 1;
  299. }
  300.  
  301. stock SendClientMessageEx(playerid, color, const str[], {Float,_}:...)
  302. {
  303.     static
  304.         args,
  305.         start,
  306.         end,
  307.         string[144]
  308.     ;
  309.     #emit LOAD.S.pri 8
  310.     #emit STOR.pri args
  311.  
  312.     if (args > 12)
  313.     {
  314.         #emit ADDR.pri str
  315.         #emit STOR.pri start
  316.  
  317.         for (end = start + (args - 12); end > start; end -= 4)
  318.         {
  319.             #emit LREF.pri end
  320.             #emit PUSH.pri
  321.         }
  322.         #emit PUSH.S str
  323.         #emit PUSH.C 144
  324.         #emit PUSH.C string
  325.         #emit PUSH.C args
  326.         #emit SYSREQ.C format
  327.  
  328.         SendClientMessage(playerid, color, string);
  329.  
  330.         #emit LCTRL 5
  331.         #emit SCTRL 4
  332.         #emit RETN
  333.     }
  334.     return SendClientMessage(playerid, color, str);
  335. }
  336.  
  337. CMD:carreras(playerid, params[])
  338. {
  339.     new count = GetActiveRaces(), string[54];
  340.     format(string, sizeof(string), "%d", count);
  341.     SendClientMessage(playerid, -1, string);
  342.     return 1;
  343. }
  344.  
  345. public OnGameModeExit()
  346. {
  347.     return 1;
  348. }
  349.  
  350. public OnPlayerRequestClass(playerid, classid)
  351. {
  352.     SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  353.     SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  354.     SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  355.     return 1;
  356. }
  357.  
  358. public OnPlayerConnect(playerid)
  359. {
  360.     return 1;
  361. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement