Hi, I'm pretty new to this.
It appears I am doing something wrong in my script and if anyone can give some pointers it'd be much appreciated.
I am trying to get a random player that is currently connected to the server, then getting that players name and printing a message to all clients every 60 seconds using that players name in the message string.
I'm also going to randomly select a string from an array of predefined strings but I believe I can manage that.
Thanks, Zero.
Code:
public OnPluginStart()
{
PrintToServer("Etc Etc Plugin Started");
TimedEvent();
}
public Action:Timer_Repeat(Handle:Timer)
{
int rndNum = GetRandomInt(1,5);
new iClient = GetRandomClient();
decl String:name[32];
GetClientName(iClient, name, sizeof(name));
PrintToChatAll("Player %s was randomly chosen.", name);
}
void TimedEvent()
{
CreateTimer(60.0, Timer_Repeat, _, TIMER_REPEAT);
}
void GetRandomClient()
{
new clients[MaxClients+1], clientCount;
for (new i = 1; i <=MaxClients; i++)
{
if (IsClientInGame(i))
{
clients[clientCount++] = i;
}
return (clientCount == 0) ? -1 : clients[GetRandomInt(0, clientCount-1)];
}
}