AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   script problem, help please? (https://forums.alliedmods.net/showthread.php?t=61167)

piMpiN 09-23-2007 00:56

script problem, help please?
 
Hey guys, I'm new to scripting and I thought I'd start off really easy but I guess I went the wrong way when creating this plugin?

I'm making a plugin to display a msg every couple of minutes or so, it's just not working. Help please!


/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Ads"
#define VERSION "1.0"
#define AUTHOR "nuki"

public plugin_init()
register_plugin(PLUGIN, VERSION, AUTHOR)

public client_authorized(id)
{
set_task(400.0, "PrintText", id = "0", repeat = "b")
}
public PrintText(id)
{
client_print(id, print_chat, "Message that will be displayed")
}

Thanks

ConnorMcLeod 09-23-2007 01:08

Re: script problem, help please?
 
-edited-

Lord_Destros 09-23-2007 01:29

Re: script problem, help please?
 
Code:
#include <amxmodx> #define PLUGIN "Ads" #define VERSION "1.0" #define AUTHOR "nuki" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     set_task(10.0,"PrintText", 0,_,_, "b") } public PrintText(id) {     client_print(id, print_chat, "Message that will be displayed") }

The problem with the way connorr did it is that it prints the selected more rapidly based on how many people have joined the server (and theres no reason call it on client_putinserver unless you want it to display as soon as they enter).

ConnorMcLeod 09-23-2007 01:32

Re: script problem, help please?
 
Sure, i was just thinking of that, after posted...

Either you do 1 task per player that basically is bad :
Code:
#include <amxmodx> #define PLUGIN "Ads" #define VERSION "1.0" #define AUTHOR "nuki" #define TASKID 123456 public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR) } public client_connect(id) {     set_task(400.0, "PrintText", id+TASKID, _, _, "b") } public client_disconnect(id) {     remove_task(id+TASKID) } public PrintText(id) {     id -= TASKID     client_print(id, print_chat, "Message that will be displayed") }

either you make only 1 task for all players that is better :
Code:
#include <amxmod> #define PLUGIN "Ads" #define VERSION "1.0" #define AUTHOR "nuki" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR) } public plugin_cfg() {     set_task(400.0, "PrintText", _, _, _, "b") } public PrintText() {     client_print(0, print_chat, "Message that will be displayed") }

piMpiN 09-23-2007 11:14

Re: script problem, help please?
 
That's great, Thanks guys... I see the mistake I made, you guys rock!


All times are GMT -4. The time now is 16:11.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.