mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-23 05:30:39 -05:00
Stable v0.8
This commit is contained in:
87
Admin/m2demo/admin/main.gsc
Normal file
87
Admin/m2demo/admin/main.gsc
Normal file
@ -0,0 +1,87 @@
|
||||
#include maps\mp\_utility;
|
||||
#include settings\main;
|
||||
#include admin\commands;
|
||||
|
||||
initIW4MAdmin()
|
||||
{
|
||||
Settings = LoadSettings();
|
||||
setDvarIfUninitialized(Settings["dvar_prefix"] + "_lastevent", ""); // | COMMAND | ORIGIN npID | TARGET npID | OPT DATA
|
||||
|
||||
thread waitEvent();
|
||||
level thread onPlayerConnect();
|
||||
}
|
||||
|
||||
onPlayerConnect()
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
level waittill( "connected", player );
|
||||
player setClientDvar("cg_chatHeight", 8);
|
||||
}
|
||||
}
|
||||
|
||||
waitEvent()
|
||||
{
|
||||
level endon ("disconnect");
|
||||
Settings = LoadSettings();
|
||||
|
||||
while (true)
|
||||
{
|
||||
lastEvent = getDvar(Settings["dvar_prefix"] + "_lastevent");
|
||||
|
||||
if (lastEvent != "")
|
||||
{
|
||||
event = strtok(lastEvent, ";");
|
||||
event["command"] = event[0];
|
||||
event["origin"] = getPlayerByGUID(event[1]);
|
||||
event["target"] = getPlayerByGUID(event[2]);
|
||||
event["data"] = event[3];
|
||||
PrintLnConsole("Event " + event["command"] + " from " + event["origin"].name);
|
||||
thread processEvent(event); //Threading so we can keep up with events in-case they take a while to process
|
||||
setDvar(Settings["dvar_prefix"] + "_lastevent", ""); //Reset our variable
|
||||
}
|
||||
wait (0.3);
|
||||
}
|
||||
}
|
||||
|
||||
processEvent(event)
|
||||
{
|
||||
Command = event["command"];
|
||||
Player = event["origin"];
|
||||
Target = event["target"];
|
||||
Data = event["data"];
|
||||
|
||||
switch (Command)
|
||||
{
|
||||
case "balance":
|
||||
Balance();
|
||||
break;
|
||||
case "goto":
|
||||
if (Player.goto == true)
|
||||
{
|
||||
Player notify("spectate_finished");
|
||||
Player.goto = false;
|
||||
}
|
||||
else
|
||||
Player GoTo(Target);
|
||||
break;
|
||||
case "alert":
|
||||
Player Alert(Data);
|
||||
break;
|
||||
case "tell":
|
||||
Target Tell(Data, Player);
|
||||
break;
|
||||
default:
|
||||
Player Tell("You entered an invalid command!");
|
||||
}
|
||||
}
|
||||
|
||||
getPlayerByGUID(GUID)
|
||||
{
|
||||
foreach (noob in level.players)
|
||||
{
|
||||
if (noob.guid == GUID)
|
||||
return noob;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user