Hey, just recently started learning Sourcepawn and I'm trying to figure out how to reply with a random response from an array of strings. From looking around, an array is strings is done differently, but I'm not confident how to do it properly.
This is what I've currently got, but when run in server, I get random numbers rather than the actual strings (I get the same random numbers, so I'm assuming it's replacing these strings with those numbers).
PHP Code:
#include <sourcemod>
#include <cstrike>
#include <sdktools>
#pragma semicolon 1
#pragma newdecls required
public Plugin myinfo =
{
name = "RandomFactTest",
author = "Diazg",
description = "Replies with a random fact",
version = "1.0.0",
url = ""
};
public void OnPluginStart()
{
RegConsoleCmd("sm_fact", Random_Facts, "Prints a random fact");
}
public Action Random_Facts(int client, int args)
{
char RandomFacts[5][] = {"Fact Test1", "Fact Test2", "Fact Test3", "Fact Test4", "Fact Test5"};
int randomnum = GetRandomInt(0, 4);
ReplyToCommand(client, "%d", RandomFacts[randomnum]);
return Plugin_Handled;
}
Any assistance/explanation is more than welcomed and appreciated. Thank you in advance.