Advertisement
Guest User

Untitled

a guest
May 26th, 2015
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.92 KB | None | 0 0
  1. /*
  2. * MTA maploader
  3. * By IPrototypeI
  4. * Thanks to [DT]Sniper for adding a new optional parameter for the function LoadMap to change the z coordinate of the map.
  5. */
  6.  
  7. /*
  8. * Native
  9. * native LoadMap(path[],Float:offset);
  10. * native RestartRace();
  11. * native StartRace(time);
  12. * LoadRandomMap(Float:offset);
  13. * Callback
  14. * OnPlayerFinishRace(playerid);
  15. */
  16. #if !defined _sscanf2_included
  17. #include <sscanf2>
  18. #endif
  19.  
  20. #if !defined _streamer_included
  21. #include <streamer>
  22. #endif
  23.  
  24. #if !defined _filemanager_included
  25. #include <filemanager>
  26. #endif
  27.  
  28. #define GetMapName() LoadData[lLastMapName]
  29.  
  30. enum mapData {
  31. pMmodelid,
  32. pMcolorID,
  33. pMtype[30],
  34. Float:pMX,
  35. Float:pMY,
  36. Float:pMZ,
  37. Float:pMRX,
  38. Float:pMRY,
  39. Float:pMRZ,
  40. Float:pNMRZ,
  41. }
  42.  
  43. native IsValidVehicle(vehicleid);
  44.  
  45. enum lData {
  46. lLastMapName[128],
  47. lLastMap,
  48. lMaxMaps,
  49. lTimerID,
  50. };
  51.  
  52. new LoadData[lData];
  53.  
  54. static const VehicleNames[212][20 char] = {
  55. {!"Landstalker"},{!"Bravura"},{!"Buffalo"},{!"Linerunner"},{!"Perrenial"},{!"Sentinel"},{!"Dumper"},
  56. {!"Firetruck"},{!"Trashmaster"},{!"Stretch"},{!"Manana"},{!"Infernus"},{!"Voodoo"},{!"Pony"},{!"Mule"},
  57. {!"Cheetah"},{!"Ambulance"},{!"Leviathan"},{!"Moonbeam"},{!"Esperanto"},{!"Taxi"},{!"Washington"},
  58. {!"Bobcat"},{!"Mr Whoopee"},{!"BF Injection"},{!"Hunter"},{!"Premier"},{!"Enforcer"},{!"Securicar"},
  59. {!"Banshee"},{!"Predator"},{!"Bus"},{!"Rhino"},{!"Barracks"},{!"Hotknife"},{!"Trailer 1"},{!"Previon"},
  60. {!"Coach"},{!"Cabbie"},{!"Stallion"},{!"Rumpo"},{!"RC Bandit"},{!"Romero"},{!"Packer"},{!"Monster"},
  61. {!"Admiral"},{!"Squalo"},{!"Seasparrow"},{!"Pizzaboy"},{!"Tram"},{!"Trailer 2"},{!"Turismo"},
  62. {!"Speeder"},{!"Reefer"},{!"Tropic"},{!"Flatbed"},{!"Yankee"},{!"Caddy"},{!"Solair"},{!"Berkley's RC Van"},
  63. {!"Skimmer"},{!"PCJ-600"},{!"Faggio"},{!"Freeway"},{!"RC Baron"},{!"RC Raider"},{!"Glendale"},{!"Oceanic"},
  64. {!"Sanchez"},{!"Sparrow"},{!"Patriot"},{!"Quad"},{!"Coastguard"},{!"Dinghy"},{!"Hermes"},{!"Sabre"},
  65. {!"Rustler"},{!"ZR-350"},{!"Walton"},{!"Regina"},{!"Comet"},{!"BMX"},{!"Burrito"},{!"Camper"},{!"Marquis"},
  66. {!"Baggage"},{!"Dozer"},{!"Maverick"},{!"News Chopper"},{!"Rancher"},{!"FBI Rancher"},{!"Virgo"},{!"Greenwood"},
  67. {!"Jetmax"},{!"Hotring"},{!"Sandking"},{!"Blista Compact"},{!"Police Maverick"},{!"Boxville"},{!"Benson"},
  68. {!"Mesa"},{!"RC Goblin"},{!"Hotring Racer A"},{!"Hotring Racer B"},{!"Bloodring Banger"},{!"Rancher"},
  69. {!"Super GT"},{!"Elegant"},{!"Journey"},{!"Bike"},{!"Mountain Bike"},{!"Beagle"},{!"Cropdust"},{!"Stunt"},
  70. {!"Tanker"}, {!"Roadtrain"},{!"Nebula"},{!"Majestic"},{!"Buccaneer"},{!"Shamal"},{!"Hydra"},{!"FCR-900"},
  71. {!"NRG-500"},{!"HPV1000"},{!"Cement Truck"},{!"Tow Truck"},{!"Fortune"},{!"Cadrona"},{!"FBI Truck"},
  72. {!"Willard"},{!"Forklift"},{!"Tractor"},{!"Combine"},{!"Feltzer"},{!"Remington"},{!"Slamvan"},
  73. {!"Blade"},{!"Freight"},{!"Streak"},{!"Vortex"},{!"Vincent"},{!"Bullet"},{!"Clover"},{!"Sadler"},
  74. {!"Firetruck LA"},{!"Hustler"},{!"Intruder"},{!"Primo"},{!"Cargobob"},{!"Tampa"},{!"Sunrise"},{!"Merit"},
  75. {!"Utility"},{!"Nevada"},{!"Yosemite"},{!"Windsor"},{!"Monster A"},{!"Monster B"},{!"Uranus"},{!"Jester"},
  76. {!"Sultan"},{!"Stratum"},{!"Elegy"},{!"Raindance"},{!"RC Tiger"},{!"Flash"},{!"Tahoma"},{!"Savanna"},
  77. {!"Bandito"},{!"Freight Flat"},{!"Streak Carriage"},{!"Kart"},{!"Mower"},{!"Duneride"},{!"Sweeper"},
  78. {!"Broadway"},{!"Tornado"},{!"AT-400"},{!"DFT-30"},{!"Huntley"},{!"Stafford"},{!"BF-400"},{!"Newsvan"},
  79. {!"Tug"},{!"Trailer 3"},{!"Emperor"},{!"Wayfarer"},{!"Euros"},{!"Hotdog"},{!"Club"},{!"Freight Carriage"},
  80. {!"Trailer 3"},{!"Andromada"},{!"Dodo"},{!"RC Cam"},{!"Launch"},{!"Police Car (LSPD)"},{!"Police Car (SFPD)"},
  81. {!"Police Car (LVPD)"},{!"Police Ranger"},{!"Picador"},{!"S.W.A.T. Van"},{!"Alpha"},{!"Phoenix"},{!"Glendale"},
  82. {!"Sadler"},{!"Luggage Trailer A"},{!"Luggage Trailer B"},{!"Stair Trailer"},{!"Boxville"},{!"Farm Plow"},
  83. {!"Utility Trailer"}
  84. };
  85.  
  86. forward OnPlayerFinishRace(playerid);
  87. forward @Countdown(time);
  88.  
  89. #if !defined _ALS_
  90. forward public _ALS_();
  91. _ALS_()<_ALS_:unhooked>{}
  92. _ALS_()<_ALS_:hooked>{}
  93. _ALS_()<>{}
  94. #endif
  95.  
  96. public OnGameModeInit()
  97. {
  98. state _ALS_:hooked;
  99. Streamer_VisibleItems(STREAMER_TYPE_OBJECT,1000);
  100. Streamer_SetTickRate(25);
  101. InitalizeMaps();
  102. return H_OnGameModeInit();
  103. }
  104. forward H_OnGameModeInit();
  105. #if defined _ALS_OnGameModeInit
  106. #undef OnGameModeInit
  107. #else
  108. #define _ALS_OnGameModeInit
  109. #endif
  110. public H_OnGameModeInit() <_ALS_:unhooked> return 1;
  111. public H_OnGameModeInit() <> return 1;
  112. #define OnGameModeInit(%0) H_OnGameModeInit(%0)<_ALS_:hooked>
  113.  
  114. public OnPlayerEnterDynamicArea(playerid, areaid)
  115. {
  116. state _ALS_:hooked;
  117. new kind = Streamer_GetIntData(STREAMER_TYPE_AREA, areaid, E_STREAMER_EXTRA_ID);
  118. PlayerPlaySound(playerid, 1056, 0.0, 0.0, 0.0);
  119. switch(kind){
  120. case 1:AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
  121. case 2:RepairVehicle(GetPlayerVehicleID(playerid));
  122. case 4:{
  123. new vehicle = GetPlayerVehicleID(playerid),Float:vData[3], loadstr[40];
  124. getproperty(0, "", 1000000+areaid, loadstr);
  125. strunpack(loadstr, loadstr, sizeof(loadstr));
  126. sscanf(loadstr,"p<|>a<f>[3]",vData);
  127. SetVehicleVelocity(vehicle,vData[0],vData[1],vData[2]);
  128. }
  129. case 5:{
  130. new vehicle = GetPlayerVehicleID(playerid),Float:vData[8], loadstr[40];
  131. getproperty(0, "", 1000000+areaid, loadstr);
  132. strunpack(loadstr, loadstr, sizeof(loadstr));
  133. sscanf(loadstr,"p<|>a<f>[4]",vData);
  134. GetVehicleVelocity(vehicle,vData[5],vData[6],vData[7]);
  135. SetVehiclePos(vehicle,vData[0],vData[1],vData[2]);
  136. SetVehicleZAngle(vehicle,vData[3]);
  137. SetVehicleVelocity(vehicle,vData[5],vData[6],vData[7]);
  138. }
  139. default: {
  140. new vehicle = GetPlayerVehicleID(playerid);
  141. if(GetVehicleModel(vehicle) != kind && kind != 0){
  142. new Float:vData[7];
  143. GetVehiclePos(vehicle,vData[0],vData[1],vData[2]);
  144. GetVehicleZAngle(vehicle,vData[3]);
  145. GetVehicleVelocity(vehicle,vData[4],vData[5],vData[6]);
  146. DestroyVehicle(vehicle);
  147. vehicle = CreateVehicle(kind,vData[0],vData[1],vData[2],vData[3],random(255),random(255),-1);
  148. PutPlayerInVehicle(playerid,vehicle,0);
  149. if(kind == 425 || kind == 520){
  150. SetVehicleVelocity(vehicle,vData[4],vData[5],vData[6]+2.0);
  151. OnPlayerFinishRace(playerid);
  152. } else SetVehicleVelocity(vehicle,vData[4],vData[5],vData[6]);
  153. }
  154. }
  155. }
  156. return H_OnPlayerEnterDynamicArea(playerid, areaid);
  157. }
  158. forward H_OnPlayerEnterDynamicArea(playerid, areaid);
  159. #if defined _ALS_OnPlayerEnterDynamicArea
  160. #undef OnPlayerEnterDynamicArea
  161. #else
  162. #define _ALS_OnPlayerEnterDynamicArea
  163. #endif
  164. public H_OnPlayerEnterDynamicArea(playerid, areaid) <_ALS_:unhooked> return 1;
  165. public H_OnPlayerEnterDynamicArea(playerid, areaid) <> return 1;
  166. #define OnPlayerEnterDynamicArea(%0,%1) H_OnPlayerEnterDynamicArea(%0,%1)<_ALS_:hooked>
  167.  
  168. stock LoadRandomMap(Float:offZ = 0.0)
  169. {
  170. new rand;
  171. do {
  172. rand = random(LoadData[lMaxMaps]-10000000)+10000000;
  173. }
  174. while(LoadData[lLastMap] == rand);
  175. LoadData[lLastMap] = rand;
  176. new loadstr[100];
  177. if(!existproperty(0, "", rand))return print("Es konnte keine Map geladen werden!"),0;
  178. getproperty(0, "", rand, loadstr);
  179. strunpack(loadstr, loadstr, sizeof(loadstr));
  180. strins(loadstr,"/Racemaps/",0);
  181. strcat(loadstr,"/objects.map");
  182. return LoadMap(loadstr,offZ);
  183. }
  184.  
  185. stock LoadMap(path[], Float:offZ = 0.0){
  186. if(UnloadMap()){
  187. new loadstr[400],mapValues[mapData],count;
  188. if(!fexist(path))return 0;
  189. print(path);
  190. new length = strfind(path,"/",true,2), lstring[128];
  191. strmid(lstring,path,length,strfind(path,"/",true,++length));
  192. format(LoadData[lLastMapName],128,lstring);
  193. new File:fhandle = fopen(path,io_read);
  194. while(fread(fhandle, loadstr)){
  195. if(!loadstr[0])continue;
  196. if(!sscanf(loadstr, "p<\">'object''model='d'posX='f'posY='f'posZ='f'rotX='f'rotY='f'rotZ='f",mapValues[pMmodelid], mapValues[pMX], mapValues[pMY], mapValues[pMZ], mapValues[pMRX], mapValues[pMRY], mapValues[pMRZ])){
  197. CreateDynamicObject(mapValues[pMmodelid], mapValues[pMX], mapValues[pMY], mapValues[pMZ]+offZ, mapValues[pMRX], mapValues[pMRY], mapValues[pMRZ],-1,-1,-1,300.0,300.0);
  198. }else if(!sscanf(loadstr, "p<\">'racepickup''type='s[30]'vehicle='d'posX='f'posY='f'posZ='f'rotX='f'rotY='f'rotZ='f",mapValues[pMtype],mapValues[pMmodelid], mapValues[pMX], mapValues[pMY], mapValues[pMZ], mapValues[pMRX], mapValues[pMRY], mapValues[pMRZ])){
  199. if(strcmp(mapValues[pMtype],"nitro") == 0)CreateRacePickup(mapValues[pMX], mapValues[pMY], mapValues[pMZ]+offZ,1);
  200. else if(strcmp(mapValues[pMtype],"repair") == 0)CreateRacePickup(mapValues[pMX], mapValues[pMY], mapValues[pMZ]+offZ,2);
  201. else if(strcmp(mapValues[pMtype],"vehiclechange") == 0)CreateRacePickup(mapValues[pMX], mapValues[pMY], mapValues[pMZ]+offZ,3,mapValues[pMmodelid]);
  202. }else if(!sscanf(loadstr, "p<\">'spawnpoint''vehicle='d'posX='f'posY='f'posZ='f'rotX='f'rotY='f'rotZ='f",mapValues[pMmodelid], mapValues[pMX], mapValues[pMY], mapValues[pMZ], mapValues[pMRX], mapValues[pMRY], mapValues[pMRZ])){
  203. ++count;
  204. CreateRaceSpawn(mapValues[pMmodelid], mapValues[pMX], mapValues[pMY], mapValues[pMZ]+offZ, mapValues[pMRZ],count);
  205. }else if(!sscanf(loadstr, "p<\">'marker''color='s[10]'posX='f'posY='f'posZ='f",mapValues[pMtype],mapValues[pMX], mapValues[pMY], mapValues[pMZ])){
  206. mapValues[pMmodelid] = CreateDynamicObject(1559,mapValues[pMX], mapValues[pMY], mapValues[pMZ]+offZ,0.0,0.0,0.0,-1,-1,-1,400.0,400.0);
  207. mapValues[pMcolorID] = ConvertStringToHex(mapValues[pMtype]);
  208. SetDynamicObjectMaterial(mapValues[pMmodelid], 0, 1231, "dynsigns", "white64", mapValues[pMcolorID]);
  209. }else if(!sscanf(loadstr, "p<\">'speedboost''posX='f'posY='f'posZ='f'veloX='f'veloY='f'veloZ='f", mapValues[pMX], mapValues[pMY], mapValues[pMZ], mapValues[pMRX], mapValues[pMRY], mapValues[pMRZ])){
  210. CreateRacePickup(mapValues[pMX], mapValues[pMY], mapValues[pMZ]+offZ,4, 0 ,mapValues[pMRX], mapValues[pMRY], mapValues[pMRZ]);
  211. } else if(!sscanf(loadstr, "p<\">'teleport''posX='f'posY='f'posZ='f'nposX='f'nposY='f'nposZ='f'rotX='f'rotY='f'rotZ='f",mapValues[pMX], mapValues[pMY], mapValues[pMZ], mapValues[pMRX], mapValues[pMRY], mapValues[pMRZ],mapValues[pNMRZ],mapValues[pNMRZ],mapValues[pNMRZ])){
  212. CreateRacePickup(mapValues[pMX], mapValues[pMY], mapValues[pMZ]+offZ,5 , 0 ,mapValues[pMRX], mapValues[pMRY], mapValues[pMRZ]+offZ,mapValues[pNMRZ]);
  213. }
  214. }
  215. fclose(fhandle);
  216. if(!count)return print("Map konnte nicht geladen werden"),0;
  217. print("Map wurde geladen");
  218. strdel(path,strfind(path,"objects.map"),strlen(path));
  219. strdel(loadstr,0,sizeof(loadstr));
  220. format(loadstr,128,"%smeta.xml",path);
  221. LoadFromMeta(loadstr);
  222. }
  223. return 1;
  224. }
  225. stock static LoadFromMeta(path[]) {
  226. if(!fexist(path))return 0;
  227. new File:fhandle = fopen(path,io_read),loadstr[400];
  228. while(fread(fhandle, loadstr)){
  229. if(strfind(loadstr,"#weather") != -1){
  230. strmid(loadstr, loadstr, strfind(loadstr,"[")+1, strfind(loadstr,"]"));
  231. SetWeather(strval(loadstr));
  232. printf("meta.xml geladen");
  233. break;
  234. }
  235. }
  236. fclose(fhandle);
  237. return 1;
  238. }
  239. stock CreateRacePickup(Float:X, Float:Y, Float:Z, Kind, vehicleid = 0, Float:nX = 0.0, Float:nY = 0.0, Float:nZ = 0.0, Float:nRZ = 0.0) {
  240. new savestr[80],id;
  241. switch(Kind){
  242. case 1:{
  243. CreateDynamicObject(1010, X, Y, Z, 0.0, 0.0, 0.0,-1, -1, -1, 400.0, 400.0);
  244. Streamer_SetIntData(STREAMER_TYPE_AREA, CreateDynamicSphere(X, Y, Z, 5.0), E_STREAMER_EXTRA_ID, 1);
  245. CreateDynamic3DTextLabel("Nitro", -1, X, Y, Z, 300.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 300.0);
  246. }
  247. case 2:{
  248. CreateDynamicObject(3096, X, Y, Z, 0.0, 0.0, 0.0,-1, -1, -1, 400.0, 400.0);
  249. Streamer_SetIntData(STREAMER_TYPE_AREA, CreateDynamicSphere(X, Y, Z, 5.0), E_STREAMER_EXTRA_ID, 2);
  250. CreateDynamic3DTextLabel("Repair", -1, X, Y, Z+0.5, 300.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 300.0);
  251. }
  252. case 3:{
  253. CreateDynamicObject(1559, X, Y, Z, 0.0, 0.0, 0.0,-1, -1, -1, 400.0, 400.0);
  254. Streamer_SetIntData(STREAMER_TYPE_AREA, CreateDynamicSphere(X, Y, Z, 5.0), E_STREAMER_EXTRA_ID, vehicleid);
  255. CreateDynamic3DTextLabel(GetVehicleName(vehicleid), -1, X, Y, Z+1.0, 300.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 300.0);
  256. }
  257. case 4:{
  258. format(savestr,80,"%f|%f|%f",nX,nY,nZ);
  259. id = CreateDynamicSphere(X, Y, Z, 5.0);
  260. setproperty(0, "", 1000000+id, savestr);
  261. CreateDynamicObject(1252, X, Y, Z, 0.0, 0.0, 0.0,-1, -1, -1, 400.0, 400.0);
  262. Streamer_SetIntData(STREAMER_TYPE_AREA, id, E_STREAMER_EXTRA_ID, 4);
  263. CreateDynamic3DTextLabel("Speedboost", -1, X, Y, Z, 300.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 300.0);
  264. }
  265. case 5:{
  266. format(savestr,80,"%f|%f|%f|%f",nX,nY,nZ,nRZ);
  267. id = CreateDynamicSphere(X, Y, Z, 5.0);
  268. setproperty(0, "", 1000000+id, savestr);
  269. CreateDynamicObject(1318, X, Y, Z, 0.0, 0.0, 0.0,-1, -1, -1, 400.0, 400.0);
  270. Streamer_SetIntData(STREAMER_TYPE_AREA, id, E_STREAMER_EXTRA_ID, 5);
  271. CreateDynamic3DTextLabel("Teleports", -1, X, Y, Z+1.5, 300.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 300.0);
  272. }
  273. }
  274. return 1;
  275. }
  276.  
  277. stock InitializeRace() {
  278. new pos = 10000 + 1, loadstr[64], vw, mapValues[mapData];
  279. for(new i; i != MAX_PLAYERS; ++i){
  280. if(!IsPlayerConnected(i))continue;
  281. switch(existproperty(0, "", pos)){
  282. case true:{
  283. printf("InitializeRace");
  284. getproperty(0, "", pos, loadstr);
  285. strunpack(loadstr, loadstr, sizeof(loadstr));
  286. sscanf(loadstr,"p<|>e<i-i-s[30]fff-f-ff>",mapValues);
  287. Streamer_UpdateEx(i, mapValues[pMX],mapValues[pMY],mapValues[pMZ], vw, -1);
  288. mapValues[pMmodelid] = CreateVehicle(mapValues[pMmodelid],mapValues[pMX],mapValues[pMY],mapValues[pMZ],mapValues[pMRZ],random(255),random(255),-1);
  289. SetVehicleVirtualWorld(mapValues[pMmodelid],vw);
  290. TogglePlayerControllable(i,false);
  291. printf("%d : %s",i,mapValues[pMmodelid]);
  292. SetPlayerVirtualWorld(i,vw);
  293. PutPlayerInVehicle(i,mapValues[pMmodelid],0);
  294. }
  295. case false:{
  296. printf("InitializeRace");
  297. pos = 10000 + 1;
  298. ++vw;
  299. getproperty(0, "", pos, loadstr);
  300. strunpack(loadstr, loadstr, sizeof(loadstr));
  301. sscanf(loadstr,"p<|>e<i-i-s[30]fff-f-ff>",mapValues);
  302. Streamer_UpdateEx(i, mapValues[pMX],mapValues[pMY],mapValues[pMZ], vw, -1);
  303. mapValues[pMmodelid] = CreateVehicle(mapValues[pMmodelid],mapValues[pMX],mapValues[pMY],mapValues[pMZ],mapValues[pMRZ],random(255),random(255),-1);
  304. SetVehicleVirtualWorld(mapValues[pMmodelid],vw);
  305. TogglePlayerControllable(i,false);
  306. SetPlayerVirtualWorld(i,vw);
  307. PutPlayerInVehicle(i,mapValues[pMmodelid],0);
  308. }
  309. }
  310. ++pos;
  311. }
  312. return 1;
  313. }
  314. stock RestartRace() {
  315. KillTimer(LoadData[lTimerID]);
  316. if(RemoveVehicles())StartRace(getproperty(0, "CountdownTime"));
  317. return 1;
  318. }
  319.  
  320. stock StartRace(time){
  321. if(InitializeRace()){
  322. setproperty(.name = "CountdownTime", .value = time);
  323. return LoadData[lTimerID] = SetTimerEx("@Countdown",1000,false,"i",time);
  324. }
  325. return 1;
  326. }
  327.  
  328. @Countdown(time){
  329. new str[5];
  330. valstr(str,time/1000);
  331. time -= 1000;
  332. if(!time) {
  333. for(new i; i != MAX_PLAYERS; ++i)if(IsPlayerConnected(i))PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0),GameTextForPlayer(i, "Go Go Go", 500, 4),TogglePlayerControllable(i,true);
  334. } else {
  335. for(new i; i != MAX_PLAYERS; ++i) if(IsPlayerConnected(i))PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0),GameTextForPlayer(i, str, 500, 4);
  336. return LoadData[lTimerID] = SetTimerEx("@Countdown",1000,false,"i",time);
  337. }
  338. return 1;
  339. }
  340. stock static UnloadMap(){
  341. KillTimer(LoadData[lTimerID]);
  342. new i = 10000+1;
  343. while(existproperty(0, "", i)){
  344. deleteproperty(0, "", i);
  345. ++i;
  346. }
  347. i = 1000000+1;
  348. while(existproperty(0, "", i)){
  349. deleteproperty(0, "", i);
  350. ++i;
  351. }
  352. Streamer_DestroyAllItems(STREAMER_TYPE_OBJECT , true);
  353. Streamer_DestroyAllItems(STREAMER_TYPE_AREA , true);
  354. Streamer_DestroyAllItems(STREAMER_TYPE_3D_TEXT_LABEL , true);
  355. RemoveVehicles();
  356. print("Die Map würde erfolgreich gelöscht");
  357. return 1;
  358. }
  359. stock static ConvertStringToHex(string[],size = sizeof(string)){
  360. new stringR[10];
  361. strmid(stringR,string,7,strlen(string));
  362. strdel(string,7,strlen(string));
  363. strdel(string,0,1);
  364. strins(string,"0x",0,size);
  365. strins(string,stringR,2,size);
  366. new i, cur=1,res=0;
  367. for (i=strlen(string);i>0;i--) {
  368. if (string[i-1]<58) res=res+cur*(string[i-1]-48); else res=res+cur*(string[i-1]-65+10);
  369. cur=cur*16;
  370. }
  371. return res;
  372. }
  373. stock static GetVehicleName(modelid)
  374. {
  375. static vehName[30];
  376. strunpack(vehName, VehicleNames[modelid - 400]);
  377. return vehName;
  378. }
  379. stock RemoveVehicles(){
  380. for(new i; i != MAX_VEHICLES; ++i)DestroyVehicle(i);
  381. return 1;
  382. }
  383. stock static CreateRaceSpawn(Modelid, Float:X, Float:Y, Float:Z, Float:rZ, count) {
  384. new savestr[128];
  385. format(savestr,128,"%d|%f|%f|%f|%f",Modelid,X,Y,Z,rZ);
  386. setproperty(0, "", 10000+count, savestr);
  387. return 1;
  388. }
  389. stock static InitalizeMaps(){
  390. new dir:dHandle = dir_open("./scriptfiles/Racemaps/");
  391. new item[40], type, i= 10000000;
  392. while(dir_list(dHandle, item, type)){
  393. if(item[0] == '.')continue;
  394. setproperty(0, "", i, item);
  395. ++i;
  396. }
  397. LoadData[lMaxMaps] = i;
  398. dir_close(dHandle);
  399. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement