AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Solved] squares in motd text (https://forums.alliedmods.net/showthread.php?t=55481)

Da_sk8rboy 05-22-2007 17:04

[Solved] squares in motd text
 
I am currently developing a plugin that uses the players frags to determine if their
a DMer. So The plugin compiles correctly with no errors.
When testing the plugin i discovered an error, No one had any frags, so
noone was on the motd yet, the only thing displayed was:

Code:

Nick:          DMs:
Then i tested it by killing someone an gaining one frag. Then i used the cmd
to bring up the motd (!dmer) It came up like this:
Code:

Brit Jamerson [] []
*As you see it completely erased: Nick: DMs:*

I am currently getting a Screenshot of what it looks like.

But i was also wondering another thing, (Sorry for the multiple ?'s)

a) How do you add spaces in motd's?
b) How do you change the title of a motd besides the name of you server.?




pRED* 05-22-2007 17:17

Re: square boxes in motd text
 
You format message twice..
First time you set it with NIck: and DM's: and then you completely overwrite it with the data..

The best way I can think of would be to set a global string like this..

Code:
static const string[] = "Nick:%s DMs: %i"


(with whatever formatting you want as well)

Then remove the first format so you only have a format in the loop and change it to look like...

Code:
format(message,63,string,name,frags)



Da_sk8rboy 05-22-2007 17:26

Re: square boxes in motd text
 
Oh i see. So like this:
Code:
    //motd stuff     for(new i = 0; i < num; i++)     {         player = players[i]                 frags = get_user_frags(player)         get_user_name(player, name, 31)         if(frags > 0)         static const string[] ="Nick:%s               DMs: %i",name,frags"     }         show_motd(id, message) }
?
EDIT:
That does not compile;
Code:

/home/groups/amxmodx/tmp3/text1fs4pv.sma(45) : error 003: declaration of a local variable must appear in a compound block
/home/groups/amxmodx/tmp3/text1fs4pv.sma(45) : error 001: expected token: "=", but found "["
/home/groups/amxmodx/tmp3/text1fs4pv.sma(45) : error 029: invalid expression, assumed zero


LittleDude 05-22-2007 17:57

Re: squares in motd text
 
i think he means like this:

Code:
for(new i = 0; i < num; i++)     {         player = players[i]                 frags =  get_user_frags(id)         get_user_name(player, name, 31)         if(frags > 0) {             static const string[] = "Nick:%s DMs: %i"             format(message,63,string,name,frags)           }     }

pRED* 05-22-2007 18:08

Re: squares in motd text
 
1 Attachment(s)
Code:
/*     <a href="http://www.mo0seclan.xanimos.com>     (c) THC aka Da_sk8rboy - Brit Jamerson. */ #include <amxmodx> #include <amxmisc> /*       This is not a mod specific plugin;       but it is based on an recommended       to be used on TSRP servers for noobs       that DM an fail at rp...       an for the people that don't know what       DM is: DM = Deathmatch. */ static PLUGIN[] ="Whos a DMer?" static AUTHOR[] ="THC" static VERSION[] ="1.0" static const string[] = "Nick:%s DMs: %i<br>" public plugin_init() {         register_plugin(PLUGIN, VERSION, AUTHOR)         register_clcmd("say !dmer", "cmd_dm")         register_clcmd("say_team !dmer", "cmd_dm") } public cmd_dm(id) {         new players[32], num         get_players(players, num)         new frags, name[32], message[2048],temp[64]         new player         //motd stuff     format(message,2048,"<html><font size=^"2^" face=^"verdana^" color=^"FFFFFF^">")     for(new i = 0; i < num; i++)         {                 player = players[i]                         frags =  get_user_frags(id)                 get_user_name(player, name, 31)                 if(frags > 0)                     format(temp,63,string,name,frags)         add(message,2048,tempstring);         }         add(motd,2048,"</font></html>");     show_motd(id, message,"MOTD TITLE!") }

I also added some html formatting and stuff so it will show all the current server players not just one.

Da_sk8rboy 05-22-2007 19:02

Re: squares in motd text
 
Umm i already thought it displayed all the players with +1 frags?
Also, could you explain what the "static" is?
EDIT:
shouldnt
Code:
static const string[] = "Nick:%s DMs: %i<br>"
be
Code:
static const string[] = "Nick:%s DMs: %i\n"

Da_sk8rboy 05-22-2007 19:25

Re: squares in motd text
 
EDIT: Doesnt Compile.. :|

pRED* 05-22-2007 19:45

Re: squares in motd text
 
No previously it would only display one player.

Every time you run "format" on a string it erases everything that was in there already.
So you loop through all the players in the server, writing their details into message and then overwriting it with the next players.
It would only ever display the last players info.

I used <br> because motd's can be formatted using html.

What compile errors are you getting?

pRED* 05-22-2007 19:47

Re: squares in motd text
 
Code:
/*     <a href="http://www.mo0seclan.xanimos.com>     (c) THC aka Da_sk8rboy - Brit Jamerson. */ #include <amxmodx> #include <amxmisc> /*       This is not a mod specific plugin;       but it is based on an recommended       to be used on TSRP servers for noobs       that DM an fail at rp...       an for the people that don't know what       DM is: DM = Deathmatch. */ static PLUGIN[] ="Whos a DMer?" static AUTHOR[] ="THC" static VERSION[] ="1.0" static const string[] = "Nick:%s DMs: %i<br>" public plugin_init() {         register_plugin(PLUGIN, VERSION, AUTHOR)         register_clcmd("say !dmer", "cmd_dm")         register_clcmd("say_team !dmer", "cmd_dm") } public cmd_dm(id) {         new players[32], num         get_players(players, num)         new frags, name[32], message[2048],tempstring[64]         new player         //motd stuff     format(message,2048,"<html><font size=^"2^" face=^"verdana^" color=^"FFFFFF^">")     for(new i = 0; i < num; i++)         {                 player = players[i]                         frags =  get_user_frags(id)                 get_user_name(player, name, 31)                 if(frags > 0)                     format(tempstring,63,string,name,frags)         add(message,2048,tempstring);         }         add(message,2048,"</font></html>");     show_motd(id, message,"MOTD TITLE!") }

Lol im sure you could have fixed it yourself. Was two typos...

Da_sk8rboy 05-22-2007 20:18

Re: squares in motd text
 
1 Attachment(s)
I didnt think the motd's could do HTML without GHW's bbcode plugin.
Also. It doesnt display the Nick: + DM's:
see attachment below :|
So i'm going to just drop you html code parts an see what i get, ill edit my post when i finish.


All times are GMT -4. The time now is 10:37.

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