How are PHP codes supposed to be run in CSGO console

counter-strike-global-offensive

Context: I want to run a certain set of commands every round without binding them to a key and then pressing the key every round so that they would apply to the next round, e.g. I'll do bind "p" "[command 1]; [command 2]; [exec [file containing more commands].cfg]" and the press p every round.

  • Most of the commands I want to run apply at the beginning of the next round and last only for that round. So, if I forget, then I have to restart the entire game since, to my knowledge, there's no round version for mp_restartgame.

    • While I've seen round restarts happen a lot in CSGO professional games, I don't believe those are by a simple command or two.

I've found a thread on AlliedMods [CSGO] plugin that run specified commands at round end, where there is a PHP code to automatically run commands at the end (start) of a round that are given in a file called round_end.cfg (round_start.cfg).

Question: How do I run this PHP code?

I have tried putting this is in a cfg file which I run, but the round_start.cfg and the round_end.cfg don't seem do the trick. Forgetting for now any issues as to the correctness of the code, my question is about running PHP codes in general. Do I just put them in a cfg file which I would run? Or do I have to create or edit a BSP file using Hammer or Entspy or something?

Best Answer

Short answer:
You can't.

Long answer:

That's not PHP code. The forum there just says so, because they used a [code] tag for it and it doesn't know the code they put in there. It doesn't translate the language they put in so it will always say PHP.

It is basically like the code block we have here, just without saying "PHP" in the title:

public OnPluginStart()
{
    HookEvent("round_start", RoundStart, EventHookMode_Post)
    HookEvent("round_end", RoundEnd, EventHookMode_Post)
}

public Action:RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    ServerCommand("exec round_start.cfg");
}

public Action:RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
{
    ServerCommand("exec round_end.cfg");
}  

CSGO plugins are server side. In this case you've found a thread for a SourceMod plugin. You can not run a plugin like that as a player. You could only use them if the server runs them and provides usable commands (most notably voting commands, kick/ban for moderators, etc).

Related Topic