Random spawns according from team from MySQL
#1

Ive created spawns in Sql and they load perfectly,

but I'm having trouble with setting the positions to spawn randomly.

I want the script to check if the Spawn is on the same team for the player

it will select a random spawn from that team

then set it for the player.


this is what i have now

pawn Код:
stock PlayerSpawn(playerid)
{
    for (new i = 0; i != ReturnSpawnCounts(); ++i)
    {
        if(pInfo[playerid][pTeam] == sInfo[i][sTeam])
        {
            SetPlayerPos(playerid,sInfo[i][sPosX], sInfo[i][sPosY], sInfo[i][sPosZ]);
            SetPlayerFacingAngle(playerid, sInfo[i][sPosA]);
        }
    }
}

This doesn't work.. I just attempted to throw random things together to get my outcome. Help me out please
Reply
#2

Here you go:

Код:
stock PlayerSpawn(playerid)
{
    if(pInfo[playerid][pTeam] == sInfo[i][sTeam])
    {
        new rnd =random(4);
	if(rnd == 1)
	{
            SetPlayerPos(playerid, 0000.00000, 0000.000000, 000.000000);
            SetPlayerFacingAngle(playerid, 0000.0000);
            SendClientMessage(playerid, 0xFFFFFF00, "Spawn 1!");
	}
	if(rnd == 2)
	{
            SetPlayerPos(playerid, 0000.00000, 0000.000000, 000.000000);
            SetPlayerFacingAngle(playerid, 0000.0000);
            SendClientMessage(playerid, 0xFFFFFF00, "Spawn 2!");
	}
	if(rnd == 3)
	{
            SetPlayerPos(playerid, 0000.00000, 0000.000000, 000.000000);
            SetPlayerFacingAngle(playerid, 0000.0000);
            SendClientMessage(playerid, 0xFFFFFF00, "Spawn 3!");
	}
	if(rnd == 4)
	{
            SetPlayerPos(playerid, 0000.00000, 0000.000000, 000.000000);
            SetPlayerFacingAngle(playerid, 0000.0000);
            SendClientMessage(playerid, 0xFFFFFF00, "Spawn 4!");
	}
    }
}
Reply
#3

PHP код:
stock PlayerSpawn(playerid)
{
        new 
random(ReturnSpawnCounts());
        if(
pInfo[playerid][pTeam] == sInfo[i][sTeam])//but i think it is not necessary
        
{
            
SetPlayerPos(playerid,sInfo[i][sPosX], sInfo[i][sPosY], sInfo[i][sPosZ]);
            
SetPlayerFacingAngle(playeridsInfo[i][sPosA]);
        }

Reply
#4

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
[..]
Use the SWITCH statement!!
Reply
#5

Quote:
Originally Posted by Jebster
Посмотреть сообщение
PHP код:
stock PlayerSpawn(playerid)
{
        new 
random(ReturnSpawnCounts());
        if(
pInfo[playerid][pTeam] == sInfo[i][sTeam])//but i think it is not necessary
        
{
            
SetPlayerPos(playerid,sInfo[i][sPosX], sInfo[i][sPosY], sInfo[i][sPosZ]);
            
SetPlayerFacingAngle(playeridsInfo[i][sPosA]);
        }

I've tried this,

No luck
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)