Page 1 of 2

Help with a simple Script for Server

Posted: 10 Sep 2018, 20:17
by Ciablue
I have a question.
Will this announce when a player leaves the server?

function my_callback(%client) {
centerprintall("Character ID " @ %client.player.getCharacterId() @ " has left the world!", 8);
}
TTmod_registerPlayerLeaveCallback("my_callback");


And if its correct can I save it and the script to announce when a player joins to the same file and have it still work properly?

I know nothingnothingnothing about scripts.

Thanks

Re: Help with a simple Script for Server

Posted: 10 Sep 2018, 22:00
by Nyuton
Yes, though you will need to have different names for the functions.

Re: Help with a simple Script for Server

Posted: 10 Sep 2018, 23:34
by Ciablue
Okay
As Im am unsure if Ive done this correctly Im putting it here for you to see. Also Ive noticed there is a folder in the main folder the is called lif_scripts. Is this were I should/can house custom scripts? Lastly as far as naming the script goes. I would just save it as activity.cs and then point to it in the main.cs file?

function player_logout(%client) {
centerprintall("Character ID " @ %client.player.getCharacterId() @ " has left the world!", 8);
}
TTmod_registerPlayerLeaveCallback("player_logout");

Thank You
Cia

Re: Help with a simple Script for Server

Posted: 11 Sep 2018, 03:19
by Nyuton
That is correct.
You can put custom scripts wherever you like within the folder structure. Just need to point to the correct path and file in main.cs

Just try these things out. No need to be overly careful. In worst case your script won't load.

Re: Help with a simple Script for Server

Posted: 19 Nov 2018, 10:25
by tonkepen
I continue in this thread since it seems the most appropriate to follow my question ...

I'm not very knowledgeable about this programming language, that's why I need a little help,

I put the script on my next server ...

Code: Select all

function my_callback (% client) {
     centerprintall ("Character ID" @% client.player.getCharacterId () @ "you entered the world!", 8);
}
TTmod_registerPlayerEnterCallback ("my_callback");
Effectively works perfect, my question is how I would have to put it, so that this message would appear in the tabs of System and at the same time in Local ?.
I did tests but the truth is, I think I'm quite clumsy.

Thank you.

Re: Help with a simple Script for Server

Posted: 19 Nov 2018, 12:43
by Nyuton
That would be:

Code: Select all

// Send message to local chat:
cmChatSendLocalMessageToClient( %client, "Server", %client.player.getPosition(), " " @ "Your message..." );

// Send system chat message:
%client.cmSendClientMessage( 2475, "Your message..." );

Re: Help with a simple Script for Server

Posted: 19 Nov 2018, 12:50
by tonkepen
Thank you very much, then I understand that it could be like that, is it correct? ...

Code: Select all

function my_callback (% client) {
     cmChatSendLocalMessageToClient( %client, "Server", %client.player.getPosition(), " " @ "Your message..." );
     %client.cmSendClientMessage( 2475, "Your message..." );
}
TTmod_registerPlayerEnterCallback ("my_callback");

Re: Help with a simple Script for Server

Posted: 19 Nov 2018, 12:51
by Nyuton
that should work fine, yes

Re: Help with a simple Script for Server

Posted: 19 Nov 2018, 12:57
by tonkepen
Superrrr Thankssss

Re: Help with a simple Script for Server

Posted: 19 Nov 2018, 14:21
by tonkepen
Well, I put it the same as before, and nothing comes out, something I think I did wrong, I pass the files in case I have something wrong.

I'm sorry to be so clumsy. Thanks