UGX-Mods

Call of Duty: Black Ops 3 => Tutorial Desk => Scripting => Topic started by: MakeCents on October 04, 2016, 01:49:31 pm

Title: On Player Connect/Spawn
Post by: MakeCents on October 04, 2016, 01:49:31 pm
   On Player Connect and Spawned has changed from WAW to BO3


Code Snippet
Plaintext
init()
{
thread onPlayerConnect();
}
onPlayerConnect()
{
for(;;)
{
level waittill("connecting", player);
player thread onPlayerSpawned();
}
}
OnPlayerSpawned()
{
//do this
}

It now uses a function in another script and calls the function passed when the player connects or spawns depending which you chose

Code Snippet
Plaintext
//put this up top of script
#using scripts\shared\callbacks_shared;

function init(){
callback::on_connect( &on_player_connect );
callback::on_spawned( &on_player_spawned );
}
function on_player_connect(){
        //do stuff each time a player connects
}
function on_player_spawned(){
        //do stuff stuff each time player spawns
}
Title: Re: On Player Connect/Spawn
Post by: ToXxiCxMoDz on October 04, 2016, 03:20:26 pm
Hey, tried putting the code both above and below the main function, neither worked. Do you know whats wrong? Thanks!
Title: Re: On Player Connect/Spawn
Post by: MakeCents on October 04, 2016, 04:59:15 pm
Hey, tried putting the code both above and below the main function, neither worked. Do you know whats wrong? Thanks!

Paste your code in hastebin or something and I might be able to tell.
Title: Re: On Player Connect/Spawn
Post by: ToXxiCxMoDz on October 04, 2016, 07:27:13 pm
zm_test.gsc : http://pastebin.com/RQ4JSy1R (http://pastebin.com/RQ4JSy1R)
zm_test.csc :
http://pastebin.com/uiVs5CMt (http://pastebin.com/uiVs5CMt)
Title: Re: On Player Connect/Spawn
Post by: MakeCents on October 05, 2016, 02:06:19 pm
zm_test.gsc : http://pastebin.com/RQ4JSy1R (http://pastebin.com/RQ4JSy1R)
zm_test.csc :
http://pastebin.com/uiVs5CMt (http://pastebin.com/uiVs5CMt)

Okay, I think your problem was solved in a forum post, but for anyone that finds this, the gsc script does have the functions in it, although it was meant to put in its own script, but no other function shares the same name so you are okay with that. But you never actually call or thread the function init, that would start the whole thing, and that is why nothing is happening.


Edit: In this case, you could actually just put the on_connect lines in the main function and you don't need the init function at all.