AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to make "a = b" in AMXX scripting (https://forums.alliedmods.net/showthread.php?t=337468)

Eyup 04-23-2022 08:49

How to make "a = b" in AMXX scripting
 
Hello, I'm new at amxx scripting, How can I make "a = b"
I was a bash scripter. In bash language, when you make
Code:

a=b
echo ${b}

It gives me this output "a". How can I make this in amxx?

Natsheh 04-23-2022 09:11

Re: How to make "a = b" in AMXX scripting
 
Code:
new a, b; b = 7; a = b; server_cmd("echo a : %d  | b : %d", a, b);

Eyup 04-23-2022 10:34

Re: How to make "a = b" in AMXX scripting
 
How can I use "a" parameter in get_user_info?
For example lets say I have this code;

PHP Code:

/* Script generated by Pawn Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN    "Client Configs"
#define AUTHOR    "kramesa"
#define VERSION    "v1.0"

new a;

r;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_clcmd("say /rates""CmdRates");
}

public 
CmdRates(id)
{
    new 
iPlayers[32], iNum;
    
get_players(iPlayersiNum"ch"
    for(--
iNumiNum>=0iNum--)
    {
        new 
UserName[9], UserRate[9], UserCmdRate[9], UserUpdRate[9], UserInterp[9];
        
        
get_user_info(iPlayers[iNum], "name"UserName8);
        
get_user_info(iPlayers[iNum], "'%s'ate"aUserRate8);
        
get_user_info(iPlayers[iNum], "cl_cmdrate"UserCmdRate8);
        
get_user_info(iPlayers[iNum], "cl_updaterate"UserUpdRate8);
        
get_user_info(iPlayers[iNum], "ex_interp"UserInterp8);
        
        new 
MsgOnMotd[500];
        
formatex(MsgOnMotd499"Name: %s | Rate %s | Cmd: %s | Upd: %s | Interp: %s"UserNameUserRateUserCmdRateUserUpdRateUserInterp);
        
        
show_motd(idMsgOnMotd"Users Configs");
        return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_HANDLED;


Look at the 30th line, How can I use "a" in get_user_info?

Supremache 04-23-2022 10:46

Re: How to make "a = b" in AMXX scripting
 
a & b = number
a2[ 32 ] & b2[ 32 ] = string

new a;
a = b
get_user_info( a, "name", a2, charsmax( a2 ) );

Eyup 04-23-2022 11:02

Re: How to make "a = b" in AMXX scripting
 
I guess you didn't understand my question, Or I didn't understand your code.
The problem is, my st*p*d host is banned some codes like "rate,ip" and other stuff. So I can't use these words in my code. I'm trying to bypass it. So I wan't to use "%s" instead of "rate". I hope I could described my problem.

Supremache 04-23-2022 11:16

Re: How to make "a = b" in AMXX scripting
 
Are u talking about this line:
'a' is numeric variable so you should use number field '%d or %i'

Code:
 if you are using amx modx v1.8.3 or highter then use fmt  get_user_info(iPlayers[iNum], fmt( "'%d'ate", a ), UserRate, 8);  Or use this way formatex(MsgOnMotd, 499, "Name: %s | Rate %d%s | Cmd: %s | Upd: %s | Interp: %s", UserName, a, UserRate, UserCmdRate, UserUpdRate, UserInterp);  if you means u want to add the number as string then use num_to_str new szNum[ 10 ]; num_to_str( a,  szNum, charsmax(  szNum) ) get_user_info(iPlayers[iNum], fmt( "'%s'ate", szNum ), UserRate, 8);

zXCaptainXz 04-23-2022 11:22

Re: How to make "a = b" in AMXX scripting
 
You can do it like this
PHP Code:

new Info[] = "fate"
Info[0] = 'r' // single quote
get_user_info(iPlayers[iNum], InfoUserRate8); 


Eyup 04-23-2022 12:20

Re: How to make "a = b" in AMXX scripting
 
Quote:

Originally Posted by Supremache (Post 2777659)
Are u talking about this line:
'a' is numeric variable so you should use number field '%d or %i'

Code:
 if you are using amx modx v1.8.3 or highter then use fmt  get_user_info(iPlayers[iNum], fmt( "'%d'ate", a ), UserRate, 8);  Or use this way formatex(MsgOnMotd, 499, "Name: %s | Rate %d%s | Cmd: %s | Upd: %s | Interp: %s", UserName, a, UserRate, UserCmdRate, UserUpdRate, UserInterp);  if you means u want to add the number as string then use num_to_str new szNum[ 10 ]; num_to_str( a,  szNum, charsmax(  szNum) ) get_user_info(iPlayers[iNum], fmt( "'%s'ate", szNum ), UserRate, 8);

Tried fmt way and it show's the all player's rate as a blank. It doesn't shows anything.

Bugsy 04-23-2022 12:25

Re: How to make "a = b" in AMXX scripting
 
Try
PHP Code:

new const LetterI[] = "i";
new const 
LetterP[] = "p";

new const 
LettersRA[] = "ra";
new const 
LettersTE[] = "te";

new 
szRate];
formatexszRate charsmaxszRate ) , "%s%s" LettersRA LettersTE );

get_user_info(iPlayers[iNum], szRateUserRate8); 


Eyup 04-23-2022 12:25

Re: How to make "a = b" in AMXX scripting
 
Quote:

Originally Posted by zXCaptainXz (Post 2777660)
You can do it like this
PHP Code:

new Info[] = "fate"
Info[0] = 'r' // single quote
get_user_info(iPlayers[iNum], InfoUserRate8); 


I tried this one too and this one shows blank either.


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

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