Mooni
11-13-2014, 10:24
Well i feel like i dont even know how arrays work and im starting to get abit frusturated about it.
Im trying to chose a random client of the clients that have used the sm_c command in the first 5seconds of the round and im stuck.
I have not got to the "first 5sec" part yet, but if you think i will get problems with it feel free to help out with that aswell.
I probably dont make much sens but i would greatly appreciate some detailed examples.
What i got so far:
#include <sourcemod>
new want_c[MAXPLAYERS +1]; //Probably wrong already.
#define PLUGIN_VERSION "0.1"
#define PLUGIN_NAME "Test"
#define PLUGIN_DESCRIPTION "Trying to learn"
public Plugin:myinfo = {
name = PLUGIN_NAME,
author = "Mooni",
description = PLUGIN_DESCRIPTION,
version = PLUGIN_VERSION,
url = ""
};
public OnPluginStart()
{
RegConsoleCmd("sm_c", Command_c);
CreateTimer(5.0, Timer_5sec, TIMER_REPEAT); //idk why i made it repeat but i have not got to that yet anyway.
HookEvent("player_death", playerDeath);
HookEvent("round_start", roundStart);
CreateConVar("sm_c_version", PLUGIN_VERSION, PLUGIN_DESCRIPTION, FCVAR_REPLICATED|FCVAR_SPONLY|FCVAR_PLUGIN);
}
public Action:Command_c(client, args)
{
if(GetClientTeam(client) == CS_TEAM_CT && IsPlayerAlive(client))
{
want_c[/* idk im stupid */] = client; //here im trying to add the client to "want_c"
PrintToChat(client, "[SM] Added you to the c list.");
}
return Plugin_Continue;
}
public Action:Timer_5sec(Handle:timer)
{
if(want_c[/* idk im stupid */] !< 0)
{
GetRandomInt(1, sizeof(want_c[/* idk im stupid */]));
//Here i want to choose a random client that is in "want_c".
//And do something to that client.
//And then stop the timer and dump the list.
}
CloseHandle(Timer_5sec);
}
public Action:playerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
//if client is in "want_c", remove from "want_c".
}
public Action:roundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
//Here i want the timer to start, so i guess i should move CreateTimer here?
}
Im trying to chose a random client of the clients that have used the sm_c command in the first 5seconds of the round and im stuck.
I have not got to the "first 5sec" part yet, but if you think i will get problems with it feel free to help out with that aswell.
I probably dont make much sens but i would greatly appreciate some detailed examples.
What i got so far:
#include <sourcemod>
new want_c[MAXPLAYERS +1]; //Probably wrong already.
#define PLUGIN_VERSION "0.1"
#define PLUGIN_NAME "Test"
#define PLUGIN_DESCRIPTION "Trying to learn"
public Plugin:myinfo = {
name = PLUGIN_NAME,
author = "Mooni",
description = PLUGIN_DESCRIPTION,
version = PLUGIN_VERSION,
url = ""
};
public OnPluginStart()
{
RegConsoleCmd("sm_c", Command_c);
CreateTimer(5.0, Timer_5sec, TIMER_REPEAT); //idk why i made it repeat but i have not got to that yet anyway.
HookEvent("player_death", playerDeath);
HookEvent("round_start", roundStart);
CreateConVar("sm_c_version", PLUGIN_VERSION, PLUGIN_DESCRIPTION, FCVAR_REPLICATED|FCVAR_SPONLY|FCVAR_PLUGIN);
}
public Action:Command_c(client, args)
{
if(GetClientTeam(client) == CS_TEAM_CT && IsPlayerAlive(client))
{
want_c[/* idk im stupid */] = client; //here im trying to add the client to "want_c"
PrintToChat(client, "[SM] Added you to the c list.");
}
return Plugin_Continue;
}
public Action:Timer_5sec(Handle:timer)
{
if(want_c[/* idk im stupid */] !< 0)
{
GetRandomInt(1, sizeof(want_c[/* idk im stupid */]));
//Here i want to choose a random client that is in "want_c".
//And do something to that client.
//And then stop the timer and dump the list.
}
CloseHandle(Timer_5sec);
}
public Action:playerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
//if client is in "want_c", remove from "want_c".
}
public Action:roundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
//Here i want the timer to start, so i guess i should move CreateTimer here?
}