Raised This Month: $ Target: $400
 0% 

Solved Variable Value [Urgent]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
polimpo4
Member
Join Date: Jan 2017
Old 04-15-2018 , 23:43   Variable Value [Urgent]
Reply With Quote #1

How I Can Create A variable And Give It A String Value Like This ...

new ClanTag = "[PMN]"

and Use It Like

client_print(0,print_chat,"%i Welcome To This Test Plugin!",ClanTag)

Last edited by polimpo4; 04-16-2018 at 19:19.
polimpo4 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-16-2018 , 01:03   Re: Variable Value [Urgent]
Reply With Quote #2

Strings are arrays of characters. Use ClanTag[] = "[PMN]" and then you use %s for strings in formatting functions like client_print().
__________________
fysiks is offline
polimpo4
Member
Join Date: Jan 2017
Old 04-16-2018 , 02:22   Re: Variable Value [Urgent]
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
Strings are arrays of characters. Use ClanTag[] = "[PMN]" and then you use %s for strings in formatting functions like client_print().
I Got This Error

HTML Code:
// C:\Games\Counter-Strike\cstrike\addons\amxmodx\scripting\contas.sma(93) : error 017: undefined symbol "ClanTag"
// C:\Games\Counter-Strike\cstrike\addons\amxmodx\scripting\contas.sma(93 -- 94) : warning 215: expression has no effect
// C:\Games\Counter-Strike\cstrike\addons\amxmodx\scripting\contas.sma(94) : error 017: undefined symbol "ClanTag"
PHP Code:
if(get_cvar_num("amx_mg_level")==2)
        {
            new 
a=random_num(1,99)
            new 
b=random_num(1,10)
            
solution=a*b
line 93            ClanTag
[] = "[PMN]"
line 94            client_print(0,print_chat,"%s Solve:   %ix%i"ClanTag[],a,b)
        } 
polimpo4 is offline
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 04-16-2018 , 03:23   Re: Variable Value [Urgent]
Reply With Quote #4

Strings/arrays are called without block brackets. Basically at client_print remove "[]" after ClanTag.
__________________
Relaxing is offline
polimpo4
Member
Join Date: Jan 2017
Old 04-16-2018 , 12:05   Re: Variable Value [Urgent]
Reply With Quote #5

Quote:
Originally Posted by Relaxing View Post
Strings/arrays are called without block brackets. Basically at client_print remove "[]" after ClanTag.
Not Working

HTML Code:
//AMXXPC compile.exe
// by the AMX Mod X Dev Team


//// contas.sma
// C:\Games\Counter-Strike\cstrike\addons\amxmodx\scripting\contas.sma(91) : error 017: undefined symbol "ClanTag"
// C:\Games\Counter-Strike\cstrike\addons\amxmodx\scripting\contas.sma(91 -- 92) : warning 215: expression has no effect
// C:\Games\Counter-Strike\cstrike\addons\amxmodx\scripting\contas.sma(92) : error 017: undefined symbol "ClanTag"
// C:\Games\Counter-Strike\cstrike\addons\amxmodx\scripting\contas.sma(92) : warning 215: expression has no effect
// C:\Games\Counter-Strike\cstrike\addons\amxmodx\scripting\contas.sma(92) : warning 215: expression has no effect
// C:\Games\Counter-Strike\cstrike\addons\amxmodx\scripting\contas.sma(92) : error 001: expected token: ";", but found ")"
// C:\Games\Counter-Strike\cstrike\addons\amxmodx\scripting\contas.sma(92) : fatal error 107: too many error messages on one line
//
// Compilation aborted.
// 4 Errors.
// Could not locate output file C:\Games\Counter-Strike\cstrike\addons\amxmodx\scripting\compiled\contas.amx (compile failed).
//
// Compilation Time: 0,19 sec
// ----------------------------------------

Press enter to exit ...
PHP Code:
ClanTag[] = "[PMN]"
            
client_print(0,print_chat,"%s Solve:   %i+%i+%i",ClanTag,a,b
polimpo4 is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 04-16-2018 , 04:58   Re: Variable Value [Urgent]
Reply With Quote #6

Define the ClanTag as global variable
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
polimpo4
Member
Join Date: Jan 2017
Old 04-16-2018 , 12:07   Re: Variable Value [Urgent]
Reply With Quote #7

Quote:
Originally Posted by Natsheh View Post
Define the ClanTag as global variable
How I Can Define It? I Already Search About It And I Cannot Found It.
polimpo4 is offline
polimpo4
Member
Join Date: Jan 2017
Old 04-16-2018 , 13:11   Re: Variable Value [Urgent]
Reply With Quote #8

I Found By Myself ... It's Working Now. But Now It Give Me warning 213 tag mismatch.

The Solution To My Problem It's Here...
Apply Always The Strings To A Global And Not The Way People Are Used To Do...
Write Way To Write Code

All I Needed To Do It's This
PHP Code:
new String:clantag[] = "[PMN]" 
Thanks To All... Who Tried To Help And If Anyone Knows How To Get Rid Of tag mismatch warning Please Tell Me To Make This Code Perfectly.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>

#define PLUGIN "Calculadora PMN"
#define VERSION "1.6"
#define AUTHOR "_|Polimpo4|_"


new incompleto
new resposta
new maxtentativas[33]

new 
String:clantag[] = "[PMN]"

public plugin_init()
{
    
register_plugin(PLUGIN,VERSION,AUTHOR)
    
register_concmd("say","check",0,"Resposta - Quem Respondeu Correctamente Sera Premiado Com Vida E Colete")
    
register_cvar("amx_cm_nivel","2",FCVAR_ARCHIVE)
    
register_cvar("amx_cm_tentativas","2",FCVAR_ARCHIVE)
    
register_cvar("amx_cm_frequencia","10.0",FCVAR_ARCHIVE)
    
register_cvar("amx_cm_premio_vida","35",FCVAR_ARCHIVE)
    
register_cvar("amx_cm_premio_colete","10",FCVAR_ARCHIVE)
    
set_task(get_cvar_float("amx_cm_frequencia"),"exame")
}

public 
check(id)
{
    if(
incompleto==1)
    {
        new 
tipx[32]
        
read_argv(1,tipx,31)
        new 
tip=str_to_num(tipx)
        if(
is_user_alive(id))
        {
            if(
maxtentativas[id]>0)
            {
                if(
tip==resposta)
                {
                    
incompleto=0
                    set_user_health
(id,get_user_health(id)+get_cvar_num("amx_cm_premio_vida"))
                    
set_user_armor(id,get_user_armor(id)+get_cvar_num("amx_cm_premio_colete"))
                    
client_print(id,print_chat,"%s A Tua Resposta (%i) Esta Certa - Ganhaste %i De VIDA e %i De COLETE",clantag,tip,get_cvar_num("amx_cm_premio_vida"),get_cvar_num("amx_cm_premio_colete"))
                    new 
name[32]
                    
get_user_name(id,name,31)
                    
client_print(0,print_chat,"%s %s Respondeu (%i). Esta Correcto - Ganhou %i De VIDA e %i De COLETE",clantag,name,resposta,get_cvar_num("amx_cm_premio_vida"),get_cvar_num("amx_cm_premio_colete"))
                }
                else
                {
                    
maxtentativas[id]-=1
                    client_print
(id,print_chat,"%s A Tua Resposta -  (%i). Esta Errada! - Tentativas Restantes: %i",clantag,tip,maxtentativas[id])
                }
            }
            else
            {
                
client_print(id,print_chat,"%s Nao Tens Mais Tentativas Nesse Exame",clantag)
            }
        }
        else
        {
            
client_print(id,print_chat,"%s Atualmente Estas Morto",clantag)
        }
    }
}

public 
expirou()
{
    if(
incompleto==1)
    {
        
incompleto=0
        client_print
(0,print_chat,"%s Foram Todos Muito Lentos - Aprendam Mais Matematica - A Resposta Correta Era %i",clantag,resposta)
    }
    
set_task(get_cvar_float("amx_cm_frequencia"),"exame")
}

public 
exame()
{
    if(
get_cvar_num("amx_cm_nivel")>0)
    {
        if(
get_cvar_num("amx_cm_nivel")==1)
        {
            new 
a=random_num(1,99)
            new 
b=random_num(1,99)
            
resposta=a+b
            client_print
(0,print_chat,"%s Calcula:   %i+%i",clantag,a,b)
        }
        if(
get_cvar_num("amx_cm_nivel")==2)
        {
            new 
a=random_num(1,99)
            new 
b=random_num(1,10)
            
resposta=a+b
            client_print
(0,print_chat,"%s Calcula:   %i+%i",clantag,a,b)
        }
        if(
get_cvar_num("amx_cm_nivel")==3)
        {
            new 
a=random_num(1,99)
            new 
b=random_num(1,99)
            new 
c=random_num(1,99)
            new 
d=random_num(1,99)
            
resposta=a+b+c+d
            client_print
(0,print_chat,"%s Calcula:   %i+%i+%i+%i",clantag,a,b,c,d)
        }
        if(
get_cvar_num("amx_cm_nivel")==4)
        {
            new 
a=random_num(1,99)
            new 
b=random_num(1,99)
            new 
c=random_num(1,99)
            new 
d=random_num(1,99)
            new 
e=random_num(1,99)
            
resposta=a+b+c+d+e
            client_print
(0,print_chat,"%s Calcula:   %i+%i+%i+%i+%i",clantag,a,b,c,d,e)
        }
        if(
get_cvar_num("amx_cm_nivel")==5)
        {
            new 
a=random_num(1,99)
            new 
b=random_num(1,99)
            new 
c=random_num(1,99)
            new 
d=random_num(1,99)
            new 
e=random_num(1,99)
            new 
f=random_num(1,99)
            
resposta=a+b+c+d+e+f
            client_print
(0,print_chat,"%s Calcula:   %i+%i+%i+%i+%i+%i",clantag,a,b,c,d,e,f)
        }
        if(
get_cvar_num("amx_cm_nivel")==6)
        {
            new 
a=random_num(1,99)
            new 
b=random_num(1,99)
            new 
c=random_num(1,99)
            new 
d=random_num(1,99)
            new 
e=random_num(1,99)
            new 
f=random_num(1,99)
            new 
g=random_num(1,99)
            
resposta=a+b+c+d+e+f+g
            client_print
(0,print_chat,"%s Calcula:   %i+%i+%i+%i+%i+%i+%i",clantag,a,b,c,d,e,f,g)
        }
        if(
get_cvar_num("amx_cm_nivel")==7)
        {
            new 
a=random_num(1,99)
            new 
b=random_num(1,99)
            new 
c=random_num(1,99)
            new 
d=random_num(1,99)
            new 
e=random_num(1,99)
            new 
f=random_num(1,99)
            new 
g=random_num(1,99)
            new 
h=random_num(1,99)
            
resposta=a+b+c+d+e+f+g+h
            client_print
(0,print_chat,"%s Calcula:   %i+%i+%i+%i+%i+%i+%i+%i",clantag,a,b,c,d,e,f,g,h)
        }
        if(
get_cvar_num("amx_cm_nivel")==8)
        {
            new 
a=random_num(1,99)
            new 
b=random_num(1,99)
            new 
c=random_num(1,99)
            new 
d=random_num(1,99)
            new 
e=random_num(1,99)
            new 
f=random_num(1,99)
            new 
g=random_num(1,99)
            new 
h=random_num(1,99)
            new 
i=random_num(1,99)
            
resposta=a+b+c+d+e+f+g+h+i
            client_print
(0,print_chat,"%s Calcula:   %i+%i+%i+%i+%i+%i+%i+%i+%i",clantag,a,b,c,d,e,f,g,h,i)
        }
        if(
get_cvar_num("amx_cm_nivel")==9)
        {
            new 
a=random_num(1,99)
            new 
b=random_num(1,99)
            new 
c=random_num(1,99)
            new 
d=random_num(1,99)
            new 
e=random_num(1,99)
            new 
f=random_num(1,99)
            new 
g=random_num(1,99)
            new 
h=random_num(1,99)
            new 
i=random_num(1,99)
            new 
j=random_num(1,99)
            
resposta=a+b+c+d+e+f+g+h+i+j
            client_print
(0,print_chat,"%s Calcula:   %i+%i+%i+%i+%i+%i+%i+%i+%i+%i",clantag,a,b,c,d,e,f,g,h,i,j)
        }
        new 
iPlayers[32],iNum
        get_players
(iPlayers,iNum)
        for(new 
i=0;i<iNum;i++)
        {
            new 
id=iPlayers[i]
            if(
is_user_connected(id))
            {
                
maxtentativas[id]=get_cvar_num("amx_cm_tentativas")
            }
        }
        
incompleto=1
    
}
    
set_task(get_cvar_float("amx_cm_frequencia"),"expirou")


Last edited by polimpo4; 04-16-2018 at 13:12. Reason: errors
polimpo4 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-16-2018 , 13:12   Re: Variable Value [Urgent]
Reply With Quote #9

You should not follow sourcemod tutorials when coding for amxmodx, it's like learning java to code in C.
Drop that "String:" tag, amxmodx does not need it.
__________________

Last edited by HamletEagle; 04-16-2018 at 13:13.
HamletEagle is offline
polimpo4
Member
Join Date: Jan 2017
Old 04-16-2018 , 13:39   Re: Variable Value [Urgent]
Reply With Quote #10

Quote:
Originally Posted by HamletEagle View Post
You should not follow sourcemod tutorials when coding for amxmodx, it's like learning java to code in C.
Drop that "String:" tag, amxmodx does not need it.

Thanks A Lot. Solved

Last edited by polimpo4; 04-16-2018 at 13:41. Reason: Errors
polimpo4 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 04:43.


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