SA-MP Forums Archive
Random spawns according from team from MySQL - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Random spawns according from team from MySQL (/showthread.php?tid=480326)



Random spawns according from team from MySQL - Shockey HD - 10.12.2013

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


Re: Random spawns according from team from MySQL - SickAttack - 10.12.2013

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!");
	}
    }
}



Re: Random spawns according from team from MySQL - Jebster - 10.12.2013

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]);
        }




Re: Random spawns according from team from MySQL - Biesmen - 10.12.2013

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


Re: Random spawns according from team from MySQL - Shockey HD - 12.12.2013

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