detecting map
#1

so i was playing around and i was trying to get the script to know what map is going to be loaded now


so i've done this

Код:
public StartNewMap()
{

   for(new i = 0; i < MAX_PLAYERS; i++) {
		SpawnPlayer(i);


		if(gMapSpawns1 == 1) {
		
		   SendClientMessage(i, -1, "{FFFF99}[SERVER]: The map has been changed! (Map: Los Santos)");
		}
		else if(gMapSpawns2 == 1) {

		   SendClientMessage(i, -1, "{FFFF99}[SERVER]: The map has been changed! (Map: Bayside)");
		}
		else if(gMapSpawns3 == 1) {

		   SendClientMessage(i, -1, "{FFFF99}[SERVER]: The map has been changed! (Map: Las Payasdas)");
		}
  }

   return 1;
}
Код:
new Float:gMapSpawns1[][]= { // Los Santos
{2161.4529,-1639.9576,14.2731},
{2250.9717,-1650.3555,15.4772},
{2245.1152,-1704.1963,22.8594},
{2317.3740,-1748.8496,13.3822},
{2352.1912,-1673.8510,13.5314},
{2427.8057,-1612.1277,26.6325},
{2513.1516,-1659.7305,13.6431},
{2522.6194,-1752.0939,13.5469},
{2463.5796,-1794.1737,13.6728}
};

new Float:gMapSpawns2[][]= { // Bayside
{-2237.6675,2353.6357,4.9804},
{-2244.4297,2382.6162,5.0651},
{-2280.8123,2288.3540,4.9592},
{-2349.1038,2422.4600,7.3348},
{-2379.6294,2443.7397,10.1694},
{-2386.5432,2446.7439,10.1694},
{-2408.1724,2454.0754,13.0031}, 
{-2472.1128,2450.4846,17.3230}, 
{-2479.6860,2449.3577,17.3230}, 
{-2422.2366,2492.0024,13.1417},
{-2446.1724,2491.9753,15.3203}
};

new Float:gMapSpawns3[][]= { // Las payasdas
{-150.0970,2688.6575,62.4297}, // 1
{-169.3251,2707.1938,62.5284}, // 2
{-160.7115,2727.9463,62.1849}, // 3
{-156.2372,2758.1042,62.6473}, // 4
{-164.8217,2768.1755,62.6875}, // 5
{-201.7420,2772.7991,62.1883}, // 6
{-219.7275,2766.4863,62.6875}, // 7
{-233.2206,2807.5701,62.0547}, // 8
{-257.9517,2781.7542,62.6875}, // 9
{-269.4338,2769.4917,61.8506}, // 10
{-286.9100,2758.0896,62.5121}, // 11
{-275.2169,2735.6252,62.7543}, // 12
{-279.3707,2722.6626,62.4894}, // 13
{-310.2263,2726.7783,62.6875}, // 14
{-322.9379,2675.7722,63.6797}, // 15
{-300.5310,2659.4617,62.7915}, // 16
{-284.7141,2656.4978,62.7125}, // 17
{-288.9666,2691.4153,62.6875}, // 18
{-271.5916,2692.3357,62.6875}, // 19
{-242.9563,2710.5710,62.6875}, // 20
{-235.9050,2710.7034,62.9766}, // 21
{-227.4022,2710.5737,62.9766}, // 22
{-219.3902,2710.8257,62.9766}, // 23
{-208.2178,2712.3406,62.9794}, // 24
{-254.4105,2603.3188,62.8582} // 25
};
but im getting errors

Код:
C:\Users\yan\Desktop\Battlegrounds\gamemodes\gw.pwn(161) : error 033: array must be indexed (variable "gMapSpawns1")
C:\Users\yan\Desktop\Battlegrounds\gamemodes\gw.pwn(165) : error 033: array must be indexed (variable "gMapSpawns2")
C:\Users\yan\Desktop\Battlegrounds\gamemodes\gw.pwn(169) : error 033: array must be indexed (variable "gMapSpawns3")
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.
Reply
#2

Код:
public StartNewMap()
{

   for(new i = 0; i < MAX_PLAYERS; i++) {
		SpawnPlayer(i);

		for(new i = 0; i < sizeof( gMapSpawns1 ); i+) {
			if(gMapSpawns1[i] > 0) return SendClientMessage(i, -1, "{FFFF99}[SERVER]: The map has been changed! (Map: Los Santos)");
		}
  }
   return 1;
}
Reply
#3

Your code doesn't really make much sense. Think about it, you are checking if the variable that contains the array data of the map spawns is equal to 1. What should that even mean? It won't give you the data you want.

If your code is like the example I showed you (http://forum.sa-mp.com/showthread.ph...53#post4007353) then you should check if MapChange == 0 or MapChange == 1, etc...
Also use a switch statement since it is more effective with these kinds of checks.

PHP код:
switch(MapChange)
{
    case 
0SendClientMessage(i, -1"{FFFF99}[SERVER]: The map has been changed! (Map: Los Santos)");
    case 
1SendClientMessage(i, -1"{FFFF99}[SERVER]: The map has been changed! (Map: Bayside)");
    case 
2SendClientMessage(i, -1"{FFFF99}[SERVER]: The map has been changed! (Map: Las Payasdas)");

Reply
#4

thanks that worked but party,

i've made a simple command to test it

Код:
CMD:changemap(playerid, params[])
{
  
   GameTextForAll("~y~LOADING NEW MAP", 4000, 6);
   SetTimer("StartNewMap", 4000, false);
   
   return 1;
}
now it changes the map and respawns, but ONLY los santos!


Код:
public MapTimer(playerid)
{

   MapChange++;
   
   if( MapChange == MapCount )
   
   MapChange = 0;

   GameTextForAll("~y~LOADING NEW MAP", 4000, 6);
   SetTimer("StartNewMap", 4000, false);

   return 1;
}

public StartNewMap()
{

   for(new i = 0; i < MAX_PLAYERS; i++) {
      SpawnPlayer(i);


	  switch( MapChange )
	  {
	      case 0: SendClientMessage(i, -1, "{FFFF99}[SERVER]: The map has been changed! (Map: Los Santos)");
	      case 1: SendClientMessage(i, -1, "{FFFF99}[SERVER]: The map has been changed! (Map: Bayside)");
	      case 2: SendClientMessage(i, -1, "{FFFF99}[SERVER]: The map has been changed! (Map: Las Payasdas)");
	  }
  }

   return 1;
}
Reply
#5

It's because you skip the function that actually changes the map and go straight to the spawning.

PHP код:
CMD:changemap(playeridparams[])
{
   
MapTimer();
   return 
1;

This will call the MapTimer function and it will handle the map change and the GameTextForAll.
Reply
#6

thank u
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)