SA-MP Forums Archive
Making it Random - 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: Making it Random (/showthread.php?tid=306548)



Making it Random - (_AcE_) - 27.12.2011

Hi I have a command that starts a round in a random interior and i type -1 for random. so example /startround -1 and it will select a new map's id.

Well I want the game mode to start a random map's id when I type /startround -1. But instead it isnt working. This is what i did:

pawn Код:
new const Float:InteriorsB[10][] = {
{40},
{41},
{43},
{44},
{45},
{46},
{47},
{48},
{49},
{50}
};
Those are the ids of the maps that are interiors

pawn Код:
dcmd_startint(playerid,params[])
    {
        if(!IsPlayerAdmin(playerid) && Variables[playerid][Level] < aLvl[0]){return DenyPlayer(playerid);}
        if(Current != -1)return SendClientMessage(playerid,MainColors[2],"Please wait until the current round ends before starting another one.");
        if(CurrentPlayers[T_HOME] < 1 && CurrentPlayers[T_AWAY] < 1) return SendClientMessage(playerid,MainColors[2],"Not enough players.");
        if(WatchingBase == true) return SendClientMessage(playerid, MainColors[2], "Please wait until the current round ends before starting another one.");
        if(!strlen(params)) return SendClientMessage(playerid, MainColors[1], "Usage: /startbase [baseid]");
        if(CurrentPlayers[T_HOME] < 1 || CurrentPlayers[T_AWAY] < 1)return SendClientMessage(playerid, MainColors[2], "Not enough players.");
        if(strval(params) == -1)
        {
            new randint = random(sizeof(InteriorsB));
            if(!BaseExists[randint])return SendClientMessage(playerid, MainColors[2], "incorrect interior.");
            new string[128];
            format(string,sizeof(string),"*** The random %d map has now started!",randint);
            SendClientMessageToAll(COLOR_ROUND,string);
            PrepareRound();
            SetTimerEx("StartRound",5000,0,"ii",randint,0);
            return 1;
        }
        return 1;
    }
When I type the command the bases that start are also exteriors.


Re: Making it Random - Lorenc_ - 27.12.2011

Try see if this works, all you need to do is replace your array with this:

pawn Код:
new const
    Float: InteriorsB[] =
    {
        40,
        41,
        43,
        44,
        45,
        46,
        47,
        48,
        49,
        50
    }
;



Re: Making it Random - (_AcE_) - 27.12.2011

Doesn't work. Still starts exteriors.


Re: Making it Random - jamesbond007 - 27.12.2011

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
Try see if this works, all you need to do is replace your array with this:

pawn Код:
new const
    Float: InteriorsB[] =
    {
        40,
        41,
        43,
        44,
        45,
        46,
        47,
        48,
        49,
        50
    }
;
its not a float?

@OP try replacing with InteriorsB[randint][0]


Re: Making it Random - (_AcE_) - 27.12.2011

The 40 - 50 are the map numbers. Like say I /startround 12

Then it starts the 12th map..

I dont know if they are floats..


Re: Making it Random - jamesbond007 - 27.12.2011

pawn Код:
new const Float:InteriorsB[10][] = {
{40},
{41},
{43},
{44},
{45},
{46},
{47},
{48},
{49},
{50}
};

dcmd_startint(playerid,params[])
    {
        if(!IsPlayerAdmin(playerid) && Variables[playerid][Level] < aLvl[0]){return DenyPlayer(playerid);}
        if(Current != -1)return SendClientMessage(playerid,MainColors[2],"Please wait until the current round ends before starting another one.");
        if(CurrentPlayers[T_HOME] < 1 && CurrentPlayers[T_AWAY] < 1) return SendClientMessage(playerid,MainColors[2],"Not enough players.");
        if(WatchingBase == true) return SendClientMessage(playerid, MainColors[2], "Please wait until the current round ends before starting another one.");
        if(!strlen(params)) return SendClientMessage(playerid, MainColors[1], "Usage: /startbase [baseid]");
        if(CurrentPlayers[T_HOME] < 1 || CurrentPlayers[T_AWAY] < 1)return SendClientMessage(playerid, MainColors[2], "Not enough players.");
        if(strval(params) == -1)
        {
            new randint = random(sizeof(InteriorsB));
            if(!BaseExists[InteriorsB[randint][0] ])return SendClientMessage(playerid, MainColors[2], "incorrect interior.");
            new string[128];
            format(string,sizeof(string),"*** The random %d map has now started!",InteriorsB[randint][0] );
            SendClientMessageToAll(COLOR_ROUND,string);
            PrepareRound();
            SetTimerEx("StartRound",5000,0,"ii",InteriorsB[randint][0] ,0);
            return 1;
        }
        return 1;
    }