Quote:
Originally Posted by berni
Either create a string array and a cell array...
|
example, if I understand what berni means cell array
PHP Code:
// String array
new String:g_key[][] =
{
"Smoke",
"Flash",
"Godmode"
}
// Cell array
new g_value[] =
{
5000,
6000,
8000
}
public OnPluginStart()
{
RegConsoleCmd("sm_test", cmd_callback, "Test array by give number between 0 - 2");
}
public Action:cmd_callback(client, args)
{
if(args < 1) // Typed only cmd
{
ReplyToCommand(client, "Array g_key size %i, g_value size %i", sizeof(g_key), sizeof(g_value));
return Plugin_Handled;
}
new number;
new String:arg[3];
GetCmdArg(1, arg, sizeof(arg));
number = StringToInt(arg);
if(number > -1 && number < sizeof(g_key) && number < sizeof(g_value)) // Make sure not get error - [SM] Plugin encountered error 15: Array index is out of bounds
{
ReplyToCommand(client, "key %s value %i", g_key[number], g_value[number]);
}
else
{
ReplyToCommand(client, "Invalid number. Array index is out of bounds");
}
return Plugin_Handled;
}