AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [ SOLVED ] FormatEX? (https://forums.alliedmods.net/showthread.php?t=274697)

CrazY. 11-13-2015 13:06

[ SOLVED ] FormatEX?
 
How to add new parameter settings in formatex?
Code:
formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, g_zombie[player] ? g_nemesis[player] ? "CLASS_NEMESIS" : "CLASS_ZOMBIE" : g_survivor[player] ? "CLASS_SURVIVOR" : "CLASS_HUMAN")

Example:
Code:
formatex(menu, charsmax(menu), "\d%s [%L]", g_playername[player], id, g_zombie[player] ? g_nemesis[player] ? "CLASS_NEMESIS" : "CLASS_ZOMBIE" : g_survivor[player] ? "CLASS_SURVIVOR" : g_sniper[player] ? "CLASS_SNIPER" : "CLASS_HUMAN")

fysiks 11-13-2015 19:30

Re: [ HELP ] FormatEX?
 
What? formatex() is the same as format() with the exception that you can't use the destination as one of the arguments.

Have you tested your code?

CrazY. 11-14-2015 09:58

Re: [ HELP ] FormatEX?
 
No, idk the meaning of : and ? in the code.

Chihuahuax 11-14-2015 10:24

Re: [ HELP ] FormatEX?
 
its a short form of if and else perhaps

CrazY. 11-14-2015 12:05

Re: [ HELP ] FormatEX?
 
But which is the if, else, else if?

klippy 11-14-2015 12:21

Re: [ HELP ] FormatEX?
 
PHP Code:

new var;
if(
== 1337)
    var = 
42;
else
    var = 
69

is equal to:
PHP Code:

new var = (== 1337 42 69); 


fysiks 11-14-2015 12:42

Re: [ HELP ] FormatEX?
 
This is called a conditional operator, inline if (iif), or ternary if. See here: https://en.wikipedia.org/wiki/%3F:.

CrazY. 11-14-2015 13:00

Re: [ HELP ] FormatEX?
 
And for else if? : ? or ?: or dont need?

fysiks 11-14-2015 13:04

Re: [ HELP ] FormatEX?
 
Quote:

Originally Posted by CrazY. (Post 2363110)
And for else if? : ? or ?: or dont need?

else if isn't a special construct . . . i.e. you can create it with the standard if then else:

Code:

if( condition1 )
    // then
else
    if( condition2 )
        //then
    end
end

Given the code example code you posted, I would recommend that you do NOT use the ternary if since it's more difficult to understand. Use switches to determine what multilingual key that you want to use.

CrazY. 11-14-2015 13:08

Re: [ HELP ] FormatEX?
 
Hmm, Thank you for your help :fox:


All times are GMT -4. The time now is 17:55.

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