Raised This Month: $ Target: $400
 0% 

[Solved] squares in motd text


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Da_sk8rboy
Veteran Member
Join Date: Jul 2006
Old 05-22-2007 , 17:04   [Solved] squares in motd text
Reply With Quote #1

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.?



__________________
i stop around here and there.

Last edited by Da_sk8rboy; 05-24-2007 at 22:52.
Da_sk8rboy is offline
pRED*
Join Date: Dec 2006
Old 05-22-2007 , 17:17   Re: square boxes in motd text
Reply With Quote #2

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)


pRED* is offline
Da_sk8rboy
Veteran Member
Join Date: Jul 2006
Old 05-22-2007 , 17:26   Re: square boxes in motd text
Reply With Quote #3

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
__________________
i stop around here and there.

Last edited by Da_sk8rboy; 05-22-2007 at 17:52. Reason: blah
Da_sk8rboy is offline
LittleDude
Member
Join Date: Dec 2004
Location: Selah, WA
Old 05-22-2007 , 17:57   Re: squares in motd text
Reply With Quote #4

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)           }     }
__________________
It is stupid to be stupid, and stupid to not be stupid

Last edited by LittleDude; 05-22-2007 at 18:00. Reason: forgot curly brace
LittleDude is offline
Send a message via AIM to LittleDude
pRED*
Join Date: Dec 2006
Old 05-22-2007 , 18:08   Re: squares in motd text
Reply With Quote #5

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.
Attached Files
File Type: sma Get Plugin or Get Source (test.sma - 574 views - 1.3 KB)
pRED* is offline
Da_sk8rboy
Veteran Member
Join Date: Jul 2006
Old 05-22-2007 , 19:02   Re: squares in motd text
Reply With Quote #6

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"
__________________
i stop around here and there.

Last edited by Da_sk8rboy; 05-22-2007 at 19:07.
Da_sk8rboy is offline
Da_sk8rboy
Veteran Member
Join Date: Jul 2006
Old 05-22-2007 , 19:25   Re: squares in motd text
Reply With Quote #7

EDIT: Doesnt Compile..
__________________
i stop around here and there.
Da_sk8rboy is offline
pRED*
Join Date: Dec 2006
Old 05-22-2007 , 19:45   Re: squares in motd text
Reply With Quote #8

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* is offline
pRED*
Join Date: Dec 2006
Old 05-22-2007 , 19:47   Re: squares in motd text
Reply With Quote #9

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...
pRED* is offline
Da_sk8rboy
Veteran Member
Join Date: Jul 2006
Old 05-22-2007 , 20:18   Re: squares in motd text
Reply With Quote #10

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.
Attached Thumbnails
Click image for larger version

Name:	ts_lobby0000.jpg
Views:	177
Size:	53.7 KB
ID:	16311  
__________________
i stop around here and there.
Da_sk8rboy is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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