Random Spawns
#1

So I followed this tutorial https://sampforum.blast.hk/showthread.php?tid=162488.

And I am making a Cops n Robbers server.
So I want the players except the cops to spawn in random locations as in that tutorial. And I don't want the cops to get randomly spawned.

I have this under OnPlayerSpawn:
Код:
public OnPlayerSpawn(playerid)
{
	
    new Random = random(sizeof(RandomSpawns));
    SetPlayerPos(playerid, RandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2]);
    SetPlayerFacingAngle(playerid, RandomSpawns[Random][3]);
    return 1;
}
And I am having the coordinates of random locations too:
Код:
// Random Spawns
new Float:RandomSpawns[][] =
{
	{2097.2593,2473.7183,10.8203,178.1770},
	{1898.8087,2323.0466,10.8203,264.9472},
	{2172.4478,2008.0054,10.8203,88.9606},
	{2025.3451,1919.7219,12.3384,269.4235},
	{1690.7856,1449.0375,10.7660,270.6801},
	{2490.2200,1207.5165,10.8203,179.5049},
	{2653.4827,1093.5004,10.8203,86.7689},
	{1704.4315,993.5544,10.8203,90.2138},
	{1307.2826,2075.1921,10.8203,178.9650},
	{644.5126,1689.4279,6.9922,35.9316},
	{-332.7460,1549.4673,75.5625,3.8023},
	{12.9660,1179.5498,19.4441,178.5491},
	{1848.6863,2625.6885,10.8203,357.9653}
};
Now I want to make this random spawn for all the skins except for the skins 266, 265, 283, 284, and 285.
Those are the cop skins. How could I do this? Help would be greatly appreciated and I will +rep you.

Thanks,
Captain_Mani
Reply
#2

Use this stock I made:

pawn Код:
stock IsPlayerACop(playerid)
{
    if(GetPlayerSkin(playerid) == 266 || 265 || 283 || 284 || 285)
        return 1; // true
       
    return 0; // false
}
Now this can be used under OnPlayerspawn to check whether a player is a cop or not, example:
pawn Код:
if(IsPlayerACop(playerid) == 0) // if the player is not a cop
{
    new Random = random(sizeof(RandomSpawns));
    SetPlayerPos(playerid, RandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2]);
    SetPlayerFacingAngle(playerid, RandomSpawns[Random][3]);
}
if(IsPlayerACop(playerid) == 1) // the player is a cop
{
    // Code
}
Reply
#3

try this , (I didn't even test it, and it's mid-night here and Im tired, so good luck with that bro!!)

Код:
forward SetRandomSkin(playerid);
public SetRandomSkin(playerid)
{
	new randskin = random(randskin); new randskins = random(randskins);
	if(gTeam[playerid] == TEAM_COP)//change this line to the real "team cops" variable in your script
	{
		switch(randskin)
		{
	    	case 1:
	    	{
				SetPlayerSkin(playerid, 266);
		    }
		    case 2:
		    {
	            SetPlayerSkin(playerid, 265);
		    }
			case 3:
			{
				SetPlayerSkin(playerid, 283);
			}
			case 4:
			{
				SetPlayerSkin(playerid, 284);
			}
			case 5:
			{
				SetPlayerSkin(playerid, 285);
			}
		}
	}
	if(gTeam[playerid] == TEAM_ROBBERS)//change this line to the real "team robbers" variable in your script
	{
		switch(randskins)
		{
	    	case 1:
	    	{
				new skins = 0>299;
	    	    SetPlayerSkin(playerid, skins);
	    	}
		}
	}
	SetPlayerSkin(playerid, randskin);
	return 1;
}
now it can be used under etc, by just adding "SetRandomSkin(playerid);"
Reply
#4

@ Youice; Thanks for trying to help me but I want a random spawn fixed, not setting players' skins, lol. o.o


@ HellSphinX; Thanks for trying to help, but it compiles good, but in-game neither the cops nor the others spawn in random locations. Please help!
Reply
#5

How can we know if the player is a cop or not?
Reply
#6

Quote:
Originally Posted by IceMeteor
Посмотреть сообщение
How can we know if the player is a cop or not?
By the skin id.

Anyway I fixed it.
Thanks to HellSphinX.
I changed his stock to this:

Код:
stock IsPlayerACop(playerid)
{
    if(GetPlayerSkin(playerid == 266+265+283+284+285))
    	return 1; // true

    return 0; // false
}
+Repped HellSphinX for giving me a clue and fixing half of the problem.
Reply
#7

Okay then, and what is the other half problem?
Reply
#8

pawn Код:
public OnPlayerSpawn(playerid)
{
   
    if(GetPlayerSkin(playerid) != 266 && GetPlayerSkin(playerid) != 265 && GetPlayerSkin(playerid) != 283 && GetPlayerSkin(playerid) != 284 && GetPlayerSkin(playerid) != 285)
    {
    new Random = random(sizeof(RandomSpawns));
    SetPlayerPos(playerid, RandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2]);
    SetPlayerFacingAngle(playerid, RandomSpawns[Random][3]);}
    return 1;
}
Reply
#9

Quote:
Originally Posted by IceMeteor
Посмотреть сообщение
Okay then, and what is the other half problem?
The problem was with that guy's stock. His stock didn't work properly. I changed it and fixed the problem. That was the half problem.

And RoXoR, I fixed the problem.
Thanks anyway.
Reply
#10

Quote:
Originally Posted by Captain_Mani
Посмотреть сообщение
By the skin id.

Anyway I fixed it.
Thanks to HellSphinX.
I changed his stock to this:

Код:
stock IsPlayerACop(playerid)
{
    if(GetPlayerSkin(playerid == 266+265+283+284+285))
    	return 1; // true

    return 0; // false
}
+Repped HellSphinX for giving me a clue and fixing half of the problem.
Wtf? The compiler does constant math, so this will just compile to 1383. I'm surprised that it does even compile.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)