OnPlayerSpawn Hook
#1
Information 
I'm currently working on a Plugin for ZPS 3.0 in Angelscript, and after looking at the ZPS API documentation I'm trying to utilize the OnPlayerSpawn Hook, however I'm never getting inside to execute the following : 

HookReturnCode OnPlayerSpawn(CBasePlayer@ pPlayer)
{
       // Not hitting either of these
       Engine.Print(chat, pPlayer, "Hello!");
       pPlayer.setModel("models/survivors/test.mdl");
       return HOOK_HANDLED;
}
Reply
#2
"setModel" should be "SetModel", you will notice the errors in the console, or in the log file /logs/angelscript/<date>.log
Reply
#3
(12-17-2017, 11:23 AM)JonnyBoy0719 Wrote: "setModel" should be "SetModel", you will notice the errors in the console, or in the log file /logs/angelscript/<date>.log

Sorry that was a typo in my post. In my script the case is correct. Nothing in the console or log files. Additionally, the model exists at that path, and I've tested this in other areas of the code as well just to make sure. E.g. "OnPlayerSay(CBasePlayer@ pPlayer, const string& in pArgs)". 

Could it be because I'm testing the script on a LAN only server with Testmode enabled?
Reply
#4
have you registered the hook on your plugin code? (NOTE: Hooks are only available for plugins, not mapscripts)
Reply
#5
Yes I have, it looks like this : 

void PluginInit()
{

// Hooks
Events::Player::Say.Hook( @OnPlayerSay );
Events::Player::OnPlayerConnected.Hook( @OnPlayerConnected );
Events::Player::OnPlayerSpawn.Hook( @OnPlayerSpawn );

// Download / Precache Models + materials
SetupFiles();

}
Reply
#6
everything looks fine, did you add the plugin to your default_plugins.txt?
Reply
#7
Yes I have, like this:

"Plugins"
{
      "plugin"
      {
        "name" "Map Chooser"
        "script" "MapChooser"
        "lifetime" "SERVER"
        }

       "plugin"
       {
       "script" "MapVoting"
        }

        "plugin"
        {
        "name" "NewPlugin"
        "script" "NewPlugin"
         }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)