AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Choose Random Item ? (https://forums.alliedmods.net/showthread.php?t=298888)

ilostmyoldacc 06-25-2017 06:15

Choose Random Item ?
 
I'm trying to choose a random item from a item list stored in a string. How can i do that ?
My attempt:
Code:

#include <sourcemod>

static const String: Items[][] =
{
        "Item1",
        "Item2",
        "Item3"
}

public OnPluginStart()
{
        RegConsoleCmd( "items", Command_ChooseItems )
}

public Action: Command_ChooseItems( client, args )
{
        for( new i = 0; i < sizeof( Items ); i++ )
        {
                new ChoosedItem = GetRandomInt( Items[ i ] )
                PrintToChatAll( "Server choosed %s", ChoosedItem )
        }
}


Celena Luna 06-25-2017 07:03

Re: Choose Random Item ?
 
This is SourceMod, not AmxModX
Wrong place.


All times are GMT -4. The time now is 22:50.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.