Author Topic: Small code question  (Read 1164 times)

Post it anyway. Copying bits from other code is a good way to get started.
I changed from function command to joining the game and then to spawning.
Anyhow, I looked into the loop post and now I got this.

function GameConnection::SpawnPlayer(%c, %client, %filteredtext) {
   cancel($GameConnection::SpawnPlaye);
         %filteredText = filterVariableString(%unfilteredText,%brick,%client,%player);
        messageclient("\c6You got <var:cl:Test> Tests!");
   $GameConnection::SpawnPlayer = schedule(3*60000,0,thing_tick);
}


Can't get past loading objects.

console log seems to be fine.
Code: [Select]
Loading Add-On: Script_Test (CRC:-1085426497)
Executing Add-Ons/Script_Test/server.cs.
0 datablocks added.
It's something

EDIT: I didn't copy spawnplayer right and it was missing the 'r' and did something else wrong. Anyway. This is the code right now.
function GameConnection::SpawnPlayer(%client, %filteredtext) {
   cancel($GameConnection::SpawnPlayer);
         %filteredText = filterVariableString(%unfilteredText,%brick,%client,%player);
        messageclient("\c6You got <var:cl:Test> Tests!");
   $GameConnection::SpawnPlayer = schedule(1000,0,GameConnection::SpawnPlayer);
}

I can get past loading objects now, wich is nice. But I don't get the bottomprint, wich isn't so nice.
« Last Edit: June 09, 2015, 02:50:36 PM by espio100 »

Well firstly you aren't passing any function arguments in the schedule.

You're going about this all wrong. GameConnection::spawnPlayer is called whenever a player spawns or respawns. You're(for some strange reason) trying to replace the entire function and turn it into a function that just loops a bottom print to the player.

What you should be doing is creating your own function to loop the bottom print and just use gameConnection::spawnPlayer to call the looping function.

You're also incorrectly creating a variable that you're doing nothing with and calling schedule wrong.

You should be handling the bottom print like this:
Code: [Select]
%filteredText = filterVariableString("\c6You got <var:cl:Test> Tests!", %client.processingBrick,%client,%client.player);
commandToClient(%client, 'bottomPrint', %filteredText, 0, 0);

And you should be doing the schedule something like this:
Code: [Select]
$MyFunction::Schedule = %client.schedule(250, MyFunction);

wouldn't that make it so that only the last client looped would be canceled?
might be better to do $blehschedule[%client] = %client.schedule(stuff);
or %client.blehschedule = %client.schedule(stuff);
instead of $blehschedule = %client.schedule(stuff);
and then matching cancel(%client.blehschedule); or cancel($blehschedule[%client]);

personally I'd say %client.blehschedule would be better