AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Dynamic MOTD (https://forums.alliedmods.net/showthread.php?t=125271)

drekes 04-26-2010 13:32

Dynamic MOTD
 
Can someone explain how i can make dynamic motd messages?
I mean like when someones rank is in motd and it changes, to let it change in motd to.

Bugsy 04-26-2010 13:43

Re: Dynamic MOTD
 
All you do is create the motd in a string var and display it.

drekes 04-26-2010 15:10

Re: Dynamic MOTD
 
could you give an example?

wrecked_ 04-26-2010 15:16

Re: Dynamic MOTD
 
Quote:

Originally Posted by drekes (Post 1161586)
could you give an example?

https://forums.alliedmods.net/showpo...39&postcount=9

UPDATE_Hud() function.

It formats a hud message, but all you need to do is use HTML and show_motd.

drekes 04-26-2010 19:25

Re: Dynamic MOTD
 
i checked your code, but i still don't understand how i do it.

Do i make a seperate MOTD or do i code it into the plugin?

wrecked_ 04-26-2010 19:39

Re: Dynamic MOTD
 
You can do it either way, but if you're doing it in-plugin, use that method. What you're doing is basically formatting the same string, but formatting it from the end of where you previously formatted, which is what the iLen is for, basically a place holder.

If you want more info on MOTD and rankings, you can check out the stats plugins like JumpStats (Exolent) or Bullet Damage Ranking (schmurgel1983).

drekes 04-28-2010 06:33

Re: Dynamic MOTD
 
I think i understand it, but is it possible to use if and else statements in there, like this one.
PHP Code:

if(something)
{
   
len += format(motd[len], 1500-len,"<left><font color=^"red^"><B>Kills :</B> <font color=^"white^"> %d</color></left>^n"stats[0])
}
else
{
    
len += format(motd[len], 1500-len,"<left><font color=^"red^"><B>Deaths :</B> <font color=^"white^"> %d</color></left>^n"stats[1]);



wrecked_ 04-28-2010 06:54

Re: Dynamic MOTD
 
Yeah, you can, but you're better off just using the ? : operators.

drekes 04-28-2010 07:36

Re: Dynamic MOTD
 
i don't know how ? : operators work.
Could you point out a tutorial about that or explain it a bit, i looked at funcwiki but could'nt find something like that.

I found this in the pawn language guide but i don't understand a thing about it.
Code:

? : e1 ? e2 : e3
results in either e2 or e3, depending on the value of e1. The
conditional expression is a compound expression with a two
part operator, “?” and “:”. Expression e2 is evaluated if e1
is logically “true”, e3 is evaluated if e1 is logically “false”.


Bugsy 04-28-2010 08:47

Re: Dynamic MOTD
 
Quote:

Originally Posted by drekes (Post 1163192)
i don't know how ? : operators work.
Could you point out a tutorial about that or explain it a bit, i looked at funcwiki but could'nt find something like that.

I found this in the pawn language guide but i don't understand a thing about it.
Code:

? : e1 ? e2 : e3
results in either e2 or e3, depending on the value of e1. The
conditional expression is a compound expression with a two
part operator, “?” and “:”. Expression e2 is evaluated if e1
is logically “true”, e3 is evaluated if e1 is logically “false”.


This is a very simple and useful operator.

Simplest way to put it:
( condition ) ? return value if true : return value if false

PHP Code:

new Var1 0;
new 
Var2 10;

// Var1 will equal 25 here because Var2 == 10 so the condition was met. In
// this case we return the first value ( return value if true from above ).
Var1 = ( Var2 == 10 ) ? 25 100;
// Var1 now equals 25

// ------------------------------------------------------------------
new Var1 0;
new 
Var2 10;

// Var1 will equal 100 here because Var2 == 10 and our condition is checking 
// if Var2 == 15 so the condition is not met. In this case we return the 
// second value ( return value if false from above ).
Var1 = ( Var2 == 15 ) ? 25 100;
// Var1 now equals 100 

Here's how you would use this in your code from above. In that code you are using stats[0] if something is TRUE and stats[1] if something is FALSE:
PHP Code:

len += format(motd[len], 1500-len,"<left><font color=^"red^"><B>Kills :</B> <font color=^"white^"> %d</color></left>^n"something stats[0] : stats[1] ) 



All times are GMT -4. The time now is 00:33.

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