AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Solved Dhud compile error (https://forums.alliedmods.net/showthread.php?t=339254)

luciaus18 08-28-2022 09:37

Dhud compile error
 
Hi! I want to install this plugin to my server but I get this error when I want to compile:
Code:

//// amx_ads.sma
// cstrike\addons\amxmodx\scripting\amx_ads.sma(80) : error 088: number of arguments does not match definition
//
// 1 Error.
// Could not locate output file compiled\amx_ads.amx (compile failed).
//
// Compilation Time: 0.22 sec
// ----------------------------------------

Plugin:
Code:

/*
        Created in: 4/3/2019 - 12:07 (GMT+1)
        (https://forums.alliedmods.net/showthread.php?t=314756)

        Feel free to submit any request or idea :)
        |
        |
        |-->                https://forums.alliedmods.net/showthread.php?t=314756
       
        Changelog:
                v1.0 - Initial release
                v1.1 - Completely recoded, added new adverbs, added new STYLES et cetera.
                v1.2 - Added new styles, fixed a small bug.
       
              tttttt hh    EEEEEE ssssss pppppp
                tt  hh    E      ss    pp  pp
                tt  hhhhhh EEEEEE ssssss pppppp
                tt  hh  hh E          ss pp
                tt  hh  hh EEEEEE ssssss pp
               
        (https://forums.alliedmods.net/member.php?u=281156)
        (https://www.github.com/4D1G06/)
*/

#include <amxmodx>
#include <amxmisc>
#include <cromchat>
#include <dhudmessage>

#define MAX_AD_LENGTH 256
#define starts_with(%1,%2) equali(%1,%2,strlen(%2))

#define STYLE_CHAT 0
#define STYLE_HUD 1
#define STYLE_CENTER 2
#define STYLE_NOTIFY 3
#define STYLE_DHUD 4
#define STYLE_DEFAULT STYLE_CHAT // (0)

#define plugin_name "Advertisment System"
#define plugin_version "1.2"
#define plugin_author "thEsp (4D1)"

#define MAX_ADS 256 // Ehh

new ads_path[88]
new ads[MAX_ADS][MAX_AD_LENGTH]
new ad[MAX_AD_LENGTH]
new pcvar_delay,pcvar_staytime,pcvar_red,pcvar_green,pcvar_blue,ads_count,current_adnum = 0
new players_num[32],maxplayers_num[32],server_name[32],server_ip[32],map[32],game_map[32],map_type[32]
new min_players[32],iplayers,imin_players
new max_players[32],imax_players
new user_deaths[32],user_name[32],user_frags[32]
new min_frags[32],ifrags,imin_frags
new max_frags[32],imax_frags
new team[32],iteam,iplayer_team
new status[32],player_status[32]
new style = STYLE_DEFAULT
new ad_fixed[MAX_AD_LENGTH]
       
public plugin_init()
{
        register_plugin(plugin_name,plugin_version,plugin_author)
       
        pcvar_delay = register_cvar("amx_ads_delay","30")
        pcvar_staytime = register_cvar("amx_ads_hudstaytime","5")
        pcvar_red = register_cvar("amx_ads_red","0")
        pcvar_green = register_cvar("amx_ads_green","255")
        pcvar_blue = register_cvar("amx_ads_blue","0")
       
        get_configsdir(ads_path,charsmax(ads_path))
        format(ads_path,charsmax(ads_path),"%s/ads.txt",ads_path)
       
//        if(!file_exists(ads_path)) write_file(ads_path,"; This is a comment line")
       


        for(new i=0;i<get_file_lines(ads_path);i++)
        {
                read_file(ads_path,i,ads[ads_count],charsmax(ads))
                ads_count++
        }

        if(ads_count != 0) set_task(get_pcvar_float(pcvar_delay),"ShowNextAd")
}

public ShowNextAd(server)
{
check_line:
        copy(ad,charsmax(ad),ads[current_adnum]);
       
        style = STYLE_DEFAULT
       
        if(starts_with(ad,";") || starts_with(ad,"//") || equal(ad,""))
        {
                if(current_adnum==ads_count)
                {
                        current_adnum=0
                }else{
                        current_adnum++
                }
                goto check_line
        }
               
        /* Conditions */
       
        new bool:can_continue = true

condition_checker:

        /* Map */
       
        if(starts_with(ad,"[map="))
        {
                get_mapname(game_map,charsmax(game_map))
                replace(ad,charsmax(ad),"[map=","")
                split(ad,map,charsmax(map),ad,charsmax(ad),"]")
                if(equal(game_map,map))
                {
                        can_continue=true
                        goto condition_checker
                }else{
                        can_continue=false
                }
        }

        /* Map type */

        if(starts_with(ad,"[map_type="))
        {
                get_mapname(game_map,charsmax(game_map))
                replace(ad,charsmax(ad),"[map_type=","")
                split(ad,map_type,charsmax(map_type),ad,charsmax(ad),"]")
                if(starts_with(game_map,map_type))
                {
                        can_continue=true
                        goto condition_checker
                }else{
                        can_continue=false
                }
        }
       
        /* Min Players */
       
        if(starts_with(ad,"[min_players="))
        {
                replace(ad,charsmax(ad),"[min_players=","")
                split(ad,min_players,charsmax(min_players),ad,charsmax(ad),"]")
                iplayers = get_playersnum()
                imin_players = str_to_num(min_players)
                if(imin_players<=iplayers)
                {
                        can_continue=true
                        goto condition_checker
                }else{
                        can_continue=false
                }
        }

        /* Max Players */
       
        if(starts_with(ad,"[max_players="))
        {
                replace(ad,charsmax(ad),"[max_players=","")
                split(ad,max_players,charsmax(max_players),ad,charsmax(ad),"]")
                iplayers = get_playersnum()
                imax_players = str_to_num(max_players)
                if(imax_players>=iplayers)
                {
                        can_continue=true
                        goto condition_checker
                }else{
                        can_continue=false
                }
        }


        if(can_continue!=true)
        {
                if(current_adnum==ads_count)
                {
                        current_adnum=0
                } else {
                        current_adnum++
                }
                set_task(get_pcvar_float(pcvar_delay),"ShowNextAd")
                return
        }

        format(players_num,charsmax(players_num),"%i",get_playersnum())
        format(maxplayers_num,charsmax(players_num),"%i",get_maxplayers())
       
        get_mapname(map,charsmax(map))
        get_user_ip(server,server_ip,charsmax(server_ip))
        get_cvar_string("hostname",server_name,charsmax(server_name))
       
        replace_all(ad,charsmax(ad),"%players%",players_num)
        replace_all(ad,charsmax(ad),"%maxplayers%",maxplayers_num)
        replace_all(ad,charsmax(ad),"%map%",map)
        replace_all(ad,charsmax(ad),"%srvip%",server_ip)
        replace_all(ad,charsmax(ad),"%srvname%",server_name)

        format(ad_fixed,charsmax(ad_fixed),"%s",ad)
               
        for(new i=0;i<33;i++) if(is_user_connected(i))
        {
                format(ad,charsmax(ad),"%s",ad_fixed)
               
                /* ADVANCED Conditions */

adv_condition_checker:

                /* Minimum frags */

                if(starts_with(ad,"[min_frags="))
                {
                        replace(ad,charsmax(ad),"[min_frags=","")
                        split(ad,min_frags,charsmax(min_frags),ad,charsmax(ad),"]")
                        ifrags = get_user_frags(i)
                        imin_frags = str_to_num(min_frags)
               
                        if(imin_frags<=ifrags)
                        {
                                can_continue = true
                                goto adv_condition_checker
                        }else{
                                continue
                        }       
                }

                /* Maximum frags */

                if(starts_with(ad,"[max_frags="))
                {
                        replace(ad,charsmax(ad),"[max_frags=","")
                        split(ad,max_frags,charsmax(max_frags),ad,charsmax(ad),"]")
                        ifrags = get_user_frags(i)
                        imax_frags = str_to_num(max_frags)
       
                        if(imax_frags>=ifrags)
                        {
                                can_continue = true
                                goto adv_condition_checker
                        }else{
                                continue
                        }
                }

                /* Team */

                if(starts_with(ad,"[team="))
                {
                        iplayer_team = get_user_team(i)
                        replace(ad,charsmax(ad),"[team=","")
                        split(ad,team,charsmax(team),ad,charsmax(ad),"]")
                        iteam = str_to_num(team)
                        if(iteam==iplayer_team)
                        {
                                can_continue = true
                                goto adv_condition_checker
                        }else{
                                continue
                        }
                }       

                /* Alive [or dead] */

                if(starts_with(ad,"[life="))
                {
                        format(player_status,charsmax(player_status),"%s",is_user_alive(i) ? "alive" : "dead")
                        replace(ad,charsmax(ad),"[life=","")
                        split(ad,status,charsmax(status),ad,charsmax(ad),"]")
                        if(equal(status,player_status))
                        {       
                                can_continue = true
                                goto adv_condition_checker
                        }else{
                                continue
                        }
                }
                               
                style = STYLE_DEFAULT
                if(starts_with(ad,"[chat]")) style = STYLE_CHAT
                if(starts_with(ad,"[hud]")) style = STYLE_HUD
                if(starts_with(ad,"[dhud]")) style = STYLE_DHUD
                if(starts_with(ad,"[center]")) style = STYLE_CENTER
                if(starts_with(ad,"[notify]")) style = STYLE_NOTIFY
       
                switch(style) // To replace things
                {
                        case STYLE_HUD || STYLE_CENTER || STYLE_NOTIFY || STYLE_DHUD:
                        {
                                replace_all(ad,charsmax(ad),"&x01","")
                                replace_all(ad,charsmax(ad),"&x03","")
                                replace_all(ad,charsmax(ad),"&x04","")
                                replace_all(ad,charsmax(ad),"&x05","")                       
                                replace_all(ad,charsmax(ad),"&x06","")
                                replace_all(ad,charsmax(ad),"&x07","")
                        }
                }
       
                get_user_name(i,user_name,charsmax(user_name))
                format(user_deaths,charsmax(user_deaths),"%i",get_user_deaths(i))
                format(user_frags,charsmax(user_frags),"%i",get_user_frags(i))
                replace_all(ad,charsmax(ad),"%name%",user_name)
                replace_all(ad,charsmax(ad),"%deaths%",user_deaths)
                replace_all(ad,charsmax(ad),"%kills%",user_frags)
                replace_all(ad,charsmax(ad),"%frags%",user_frags)
       
                switch(style)
                {                               
                        case STYLE_HUD:
                        {
                                replace(ad,charsmax(ad),"[hud]","")
                                set_hudmessage(get_pcvar_num(pcvar_red),get_pcvar_num(pcvar_green),get_pcvar_num(pcvar_blue),-1.0,0.83,0,6.0,get_pcvar_float(pcvar_staytime))
                                show_hudmessage(i,"%s",ad)               
                        }
                        case STYLE_DHUD:
                        {
                                replace(ad,charsmax(ad),"[dhud]","")
                                set_dhudmessage(get_pcvar_num(pcvar_red),get_pcvar_num(pcvar_green),get_pcvar_num(pcvar_blue),-1.0,0.83,0,6.0,get_pcvar_float(pcvar_staytime))
                                show_dhudmessage(i,"%s",ad)               
                        }
                        case STYLE_CHAT:
                        {
                                replace(ad,charsmax(ad),"[chat]","")
                                CC_SendMessage(i,ad)
                        }
                        case STYLE_CENTER:
                        {
                                replace(ad,charsmax(ad),"[center]","")
                                client_print(i,print_center,ad)
                        }
                        case STYLE_NOTIFY:
                        {
                                replace(ad,charsmax(ad),"[notify]","")
                                client_print(i,print_notify,ad)
                        }
                }
        }
        if(current_adnum==ads_count)
        {
                current_adnum=0
        } else {
                current_adnum++
        }
        set_task(get_pcvar_float(pcvar_delay),"ShowNextAd")
}

stock get_file_lines(const filename[])
{
        if(!file_exists(filename)) return PLUGIN_CONTINUE
        new temp[3]
        new lines,file_reader = fopen(filename,"rt")
        if(!file_reader) return PLUGIN_CONTINUE
        while(!feof(file_reader))
        {
                fgets(file_reader,temp,charsmax(temp)) // Even tho is not needed, without this server/client will freeze...
                lines++
        }
        fclose(file_reader)
        return lines
}

I need some help :(

deprale 08-28-2022 13:43

Re: Dhud compile error
 
Update your AMXX version!

Compiles fine on 1.10, if I remember correctly you said you were on 1.8.2, and I checked the includes from both 1.8.2 and 1.10 and they're literally the same with the exception of &txtlen being initialized.

I downloaded 1.8.1 and checked file.inc still no changes, it really won't compile on 1.8.2 I just tested it and it's honestly confusing since on 1.10 it still has 4 arguments but it compiles fine with no issues even though
https://github.com/alliedmodders/amx.../file.cpp#L107 it wants 5 params.

So maybe an oversight from the AMXX devs, or maybe I'm retarded, no idea.

Anyway, try changing it from
PHP Code:

    for(new i=0;i<get_file_lines(ads_path);i++)
    {
        
read_file(ads_path,i,ads[ads_count],charsmax(ads))
        
ads_count++
    } 

TO
PHP Code:

for(new i=0;i<get_file_lines(ads_path);i++)
    {
        new 
temp;
        
read_file(ads_path,i,ads[ads_count],charsmax(ads), temp)
        
ads_count++
    } 

See if it works (didn't test)

EDIT: Visual studio code owned me, the "&" wasn't displayed and I was confused, it just retrieves the length it read.

luciaus18 08-28-2022 19:03

Re: Dhud compile error
 
Still nothing. I get more errors :(

fysiks 08-28-2022 19:38

Re: Dhud compile error
 
Quote:

Originally Posted by deprale (Post 2787600)
EDIT: Visual studio code owned me, the "&" wasn't displayed and I was confused

Uh, what? VS Code doesn't hide literal, printable characters.

Quote:

Originally Posted by luciaus18 (Post 2787619)
Still nothing. I get more errors :(

It compiles for me in both AMX Mod X 1.9.0 (when I get rid of the dhudmessage include since it's included in AMX Mod X 1.9.0) and 1.8.2.

If it doesn't compile for you then either you're doing something wrong or your files or compiler are corrupted. I'd recommend upgrading to 1.9.0 (then you can remove the dhudmessage include) or if you can't do that, at least re-download your version of AMX Mod X and retry compiling.

Also note that you just saying "I get errors" doesn't help us help you.

luciaus18 08-30-2022 06:27

Re: Dhud compile error
 
Quote:

Originally Posted by deprale (Post 2787600)
Update your AMXX version!

Compiles fine on 1.10, if I remember correctly you said you were on 1.8.2, and I checked the includes from both 1.8.2 and 1.10 and they're literally the same with the exception of &txtlen being initialized.

I downloaded 1.8.1 and checked file.inc still no changes, it really won't compile on 1.8.2 I just tested it and it's honestly confusing since on 1.10 it still has 4 arguments but it compiles fine with no issues even though
https://github.com/alliedmodders/amx.../file.cpp#L107 it wants 5 params.

So maybe an oversight from the AMXX devs, or maybe I'm retarded, no idea.

Anyway, try changing it from
PHP Code:

    for(new i=0;i<get_file_lines(ads_path);i++)
    {
        
read_file(ads_path,i,ads[ads_count],charsmax(ads))
        
ads_count++
    } 

TO
PHP Code:

for(new i=0;i<get_file_lines(ads_path);i++)
    {
        new 
temp;
        
read_file(ads_path,i,ads[ads_count],charsmax(ads), temp)
        
ads_count++
    } 

See if it works (didn't test)

EDIT: Visual studio code owned me, the "&" wasn't displayed and I was confused, it just retrieves the length it read.

Ok, this is what I get with this change:
Code:

//// amx_ads.sma
// cstrike\addons\amxmodx\Compiler\scripting\amx_ads.sma(81) : warning 217: loose indentation
// cstrike\addons\amxmodx\Compiler\scripting\amx_ads.sma(81) : error 088: number of arguments does not match definition
// cstrike\addons\amxmodx\Compiler\scripting\amx_ads.sma(83) : warning 203: symbol is never used: "temp"
//
// 1 Error.
// Could not locate output file compiled\amx_ads.amx (compile failed).

I wanted to keep my amxmodx 1.8.2 because of some plugins which doesn't work properly with 1.8.3 or 1.9.0.

I want to ask if someone can help me to make that dhudmessage to hudmessage. I'm not really good at that point..
I don't want to start another thread

fysiks 08-31-2022 01:22

Re: Dhud compile error
 
Quote:

Originally Posted by luciaus18 (Post 2787739)
Ok, this is what I get with this change:
Code:

//// amx_ads.sma
// cstrike\addons\amxmodx\Compiler\scripting\amx_ads.sma(81) : warning 217: loose indentation
// cstrike\addons\amxmodx\Compiler\scripting\amx_ads.sma(81) : error 088: number of arguments does not match definition
// cstrike\addons\amxmodx\Compiler\scripting\amx_ads.sma(83) : warning 203: symbol is never used: "temp"
//
// 1 Error.
// Could not locate output file compiled\amx_ads.amx (compile failed).


This means that you did not modify the code correctly. Since I can't see your modified code, I can only guess based on the errors you posted. I would guess that you created the temp variable but you did not properly add the variable to the read_file() arguments.

Quote:

Originally Posted by luciaus18 (Post 2787739)
I want to ask if someone can help me to make that dhudmessage to hudmessage. I'm not really good at that point..
I don't want to start another thread

Since it's a new topic, you should always create a new thread. That is the whole purpose of a forum, one topic per thread.

luciaus18 08-31-2022 13:52

Re: Dhud compile error
 
Quote:

Originally Posted by fysiks (Post 2787796)
This means that you did not modify the code correctly. Since I can't see your modified code, I can only guess based on the errors you posted. I would guess that you created the temp variable but you did not properly add the variable to the read_file() arguments.



Since it's a new topic, you should always create a new thread. That is the whole purpose of a forum, one topic per thread.

Oh, my bad. I didn't pay attention that there are two things to change.

Now there is one warning:
Code:

//// amx_ads.sma
// cstrike\addons\amxmodx\Compiler\scripting\amx_ads.sma(81) : warning 217: loose indentation
// Header size:          1124 bytes
// Code size:            14944 bytes
// Data size:          272708 bytes
// Stack/heap size:      16384 bytes; max. usage is unknown, due to recursion
// Total requirements:  305160 bytes
//
// 1 Warning.
// Done.


fysiks 09-01-2022 02:40

Re: Dhud compile error
 
You can ignore the loose indentation.

luciaus18 09-02-2022 10:21

Re: Dhud compile error
 
Thx mate. For now it works good

deprale 09-04-2022 03:53

Re: Dhud compile error
 
Quote:

Originally Posted by fysiks (Post 2787622)
Uh, what? VS Code doesn't hide literal, printable characters.

I had custom ligaments font and somehow the & wasn't displayed at all.


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

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