AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Ayuda? Problema con plugin showequips (https://forums.alliedmods.net/showthread.php?t=324920)

ellocofierro 06-01-2020 01:08

Ayuda? Problema con plugin showequips
 
Hola, muchas gracias por su atencion, estoy tratando de instalar el plugin Showequips y no se me "ejecuta" en el servidor basicamente no hace nada.Acá tengo el codigo del sma que al compilarlo no da ningun error:

Code:

/*################################################################################################
 _______          _______          _______  _______          _________ _______  _______
(  ____ \|\    /|(  ___  )|\    /|(  ____ \(  ___  )|\    /|\__  __/(  ____ )(  ____ \
| (    \/| )  ( || (  ) || )  ( || (    \/| (  ) || )  ( |  ) (  | (    )|| (    \/
| (_____ | (___) || |  | || | _ | || (__    | |  | || |  | |  | |  | (____)|| (_____
(_____  )|  ___  || |  | || |( )| ||  __)  | |  | || |  | |  | |  |  _____)(_____  )
      ) || (  ) || |  | || || || || (      | | /\| || |  | |  | |  | (            ) |
/\____) || )  ( || (___) || () () || (____/\| (_\ \ || (___) |___) (___| )      /\____) |
\_______)|/    \|(_______)(_______)(_______/(____\/_)(_______)\_______/|/      \_______)

This is my take on the https://forums.alliedmods.net/showthread.php?t=306558 plugin.
The code is a bit suckish and uses a lot of entities but i'm too much n00b to do it a better way :P
The sprites stay until freezetime is over and then the entities get removed so maybe it wont
interfere with gameplay.  Also the display_info task is removed when freezetime is over
so it should not consume much cpu after freeze. I hope so atleast...

If you want to disable displaying specific sprites:
#define DISPLAY_MONEY        0
#define DISPLAY_WEAPONS        0
#define DISPLAY_DOLLARSIGN        0
#define DISPLAY_ARROW        0

by DaniwA                                        2018
#################################################################################################*/

#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <cstrike>

#define DISPLAY_MONEY        1
#define DISPLAY_WEAPONS        1
#define DISPLAY_DOLLARSIGN        1
#define DISPLAY_ARROW        1

#define        PLUGIN        "SHOWEQUIPS"
#define VERSION        "1.3"
#define AUTHOR        "DaniwA"

#if DISPLAY_MONEY
#define NUMBER_OF_SPRITES        5
new userSpr[33][NUMBER_OF_SPRITES];
new tmpstr[6];
new value[2];
#endif

#if DISPLAY_WEAPONS
#define NUMBER_OF_WEAPTYPES        7
new const Float:Pistols[6] = {1.0,10.0,11.0,16.0,17.0,26.0};
new const Float:Rifles[18] = {3.0,5.0,7.0,8.0,12.0,13.0,14.0,15.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,27.0,28.0,30.0};
new userWeap[33][NUMBER_OF_WEAPTYPES];
new armor;
new weapons;
#endif

#if DISPLAY_DOLLARSIGN
new userDSign[33];
#endif

#if DISPLAY_ARROW
new userArrow[33];
#endif

new bool:NewRound;
new Float:userOrig[33][3];
new iPlayers[32], count;

public plugin_precache(){
#if DISPLAY_MONEY
        precache_model("sprites/10000.spr");
        precache_model("sprites/1000.spr");
        precache_model("sprites/100.spr");
        precache_model("sprites/10.spr");
        precache_model("sprites/1.spr");
#endif
#if DISPLAY_WEAPONS
        precache_model("sprites/weap.spr");
        precache_model("sprites/weap2.spr");
#endif
#if DISPLAY_DOLLARSIGN
        precache_model("sprites/cash.spr");
#endif
#if DISPLAY_ARROW
        precache_model("sprites/arrow.spr");
#endif
        }

public plugin_init(){
        register_plugin(PLUGIN,VERSION,AUTHOR);
        NewRound = true;
        register_event("HLTV", "event_new_round", "a", "1=0", "2=0");
        }

public event_new_round(){
        remove_task(9678);
        remove_ents();
        NewRound = true;
        set_task(get_cvar_float("mp_freezetime"),"remove_ents",9678);
        set_task(0.2,"display_info",4563,"",0,"b");
        }

public remove_ents(){
        remove_task(4563);
        for(new i; i<33; i++){
#if DISPLAY_MONEY
                for(new e; e<NUMBER_OF_SPRITES; e++)
                        remove_entity(userSpr[i][e]);
#endif
#if DISPLAY_WEAPONS
                for(new e; e<NUMBER_OF_WEAPTYPES; e++)
                        remove_entity(userWeap[i][e]);
#endif
#if DISPLAY_DOLLARSIGN
                remove_entity(userDSign[i]);
#endif
#if DISPLAY_ARROW
                remove_entity(userArrow[i]);
#endif
                }
        }

public display_info(){

        if (NewRound){
                get_players(iPlayers, count, "ah");
                }

        for(new c; c<count; c++){

                if(!is_user_alive(iPlayers[c]) || !is_user_connected(iPlayers[c]) || cs_get_user_team(iPlayers[c]) == CS_TEAM_SPECTATOR)
                        continue;

                if (NewRound){
#if DISPLAY_MONEY
                        for(new i; i<NUMBER_OF_SPRITES; i++)
                                userSpr[iPlayers[c]][i]=create_entity("env_sprite");
#endif
#if DISPLAY_WEAPONS
                        for(new i; i<NUMBER_OF_WEAPTYPES; i++)
                                userWeap[iPlayers[c]][i]=create_entity("env_sprite");
#endif
#if DISPLAY_DOLLARSIGN
                        userDSign[iPlayers[c]]=create_entity("env_sprite");
#endif
#if DISPLAY_ARROW
                        userArrow[iPlayers[c]]=create_entity("env_sprite");
#endif
                        }
       
#if DISPLAY_MONEY
                for (new x; x < NUMBER_OF_SPRITES; x++){
                        arrayset(tmpstr, 0, sizeof tmpstr);
                        num_to_str(cs_get_user_money(iPlayers[c]), tmpstr, charsmax(tmpstr))
                        value[0]=tmpstr[x];
                        value[1]=0;
                       
                        if(!tmpstr[x]){
                                switch(x){
                                        case 0: drawsprite(userSpr[iPlayers[c]][4],iPlayers[c],"sprites/10000.spr",1.0,34.0,0,0,255,0);
                                        case 1: drawsprite(userSpr[iPlayers[c]][3],iPlayers[c],"sprites/1000.spr",1.0,34.0,0,0,255,0);
                                        case 2: drawsprite(userSpr[iPlayers[c]][2],iPlayers[c],"sprites/100.spr",1.0,34.0,0,0,255,0);
                                        case 3: drawsprite(userSpr[iPlayers[c]][1],iPlayers[c],"sprites/10.spr",1.0,34.0,0,0,255,0);
                                        case 4: drawsprite(userSpr[iPlayers[c]][0],iPlayers[c],"sprites/1.spr",1.0,34.0,0,0,255,0);
                                        }
                                continue;
                                }
                               
                        switch(x){
                                case 0: drawsprite(userSpr[iPlayers[c]][4],iPlayers[c],"sprites/10000.spr",floatstr(value),34.0,255,0,255,0);
                                case 1: drawsprite(userSpr[iPlayers[c]][3],iPlayers[c],"sprites/1000.spr",floatstr(value),34.0,255,0,255,0);
                                case 2: drawsprite(userSpr[iPlayers[c]][2],iPlayers[c],"sprites/100.spr",floatstr(value),34.0,255,0,255,0);
                                case 3: drawsprite(userSpr[iPlayers[c]][1],iPlayers[c],"sprites/10.spr",floatstr(value),34.0,255,0,255,0);
                                case 4: drawsprite(userSpr[iPlayers[c]][0],iPlayers[c],"sprites/1.spr",floatstr(value),34.0,255,0,255,0);
                                }
                        }
#endif
#if DISPLAY_DOLLARSIGN
                drawsprite(userDSign[iPlayers[c]],iPlayers[c],"sprites/cash.spr",1.0,34.0,255,0,255,0);
#endif
#if DISPLAY_ARROW
                drawsprite(userArrow[iPlayers[c]],iPlayers[c],"sprites/arrow.spr",1.0,34.0,255,255,255,0);
#endif
#if DISPLAY_WEAPONS
                weapons = pev(iPlayers[c], pev_weapons);
               
                for(new i; i < sizeof Pistols; i++)
                        if(weapons & 1<<floatround(Pistols[i])){
                                drawsprite(userWeap[iPlayers[c]][0],iPlayers[c],"sprites/weap.spr",Pistols[i],50.0,255,255,255,0);
                                goto jmp1;
                                }
                drawsprite(userWeap[iPlayers[c]][0],iPlayers[c],"sprites/weap.spr",Pistols[0],50.0,0,255,255,0);
                jmp1:

                for(new i; i < sizeof Rifles; i++)
                        if(weapons & 1<<floatround(Rifles[i])){
                                drawsprite(userWeap[iPlayers[c]][1],iPlayers[c],"sprites/weap.spr",Rifles[i],50.0,255,255,255,0);
                                goto jmp2;
                                }
                drawsprite(userWeap[iPlayers[c]][1],iPlayers[c],"sprites/weap.spr",Rifles[0],50.0,0,255,255,0);
                jmp2:
               
                if(weapons & 1<<CSW_HEGRENADE)
                        drawsprite(userWeap[iPlayers[c]][2],iPlayers[c],"sprites/weap.spr",4.0,50.0,255,255,255,255);
                else
                        drawsprite(userWeap[iPlayers[c]][2],iPlayers[c],"sprites/weap.spr",4.0,50.0,0,255,255,255);
               
                if(weapons & 1<<CSW_FLASHBANG)
                        drawsprite(userWeap[iPlayers[c]][3],iPlayers[c],"sprites/weap.spr",25.0,50.0,255,255,255,255);
                else
                        drawsprite(userWeap[iPlayers[c]][3],iPlayers[c],"sprites/weap.spr",25.0,50.0,0,255,255,255);
               
                if(weapons & 1<<CSW_SMOKEGRENADE)
                        drawsprite(userWeap[iPlayers[c]][4],iPlayers[c],"sprites/weap.spr",9.0,50.0,255,255,255,255);
                else
                        drawsprite(userWeap[iPlayers[c]][4],iPlayers[c],"sprites/weap.spr",9.0,50.0,0,255,255,255);

                cs_get_user_armor(iPlayers[c],CsArmorType:armor);
                if(armor == 2)
                        drawsprite(userWeap[iPlayers[c]][5],iPlayers[c],"sprites/weap2.spr",2.0,50.0,255,0,0,255);
                else if(armor == 1)
                        drawsprite(userWeap[iPlayers[c]][5],iPlayers[c],"sprites/weap2.spr",1.0,50.0,255,0,0,255);
                else
                        drawsprite(userWeap[iPlayers[c]][5],iPlayers[c],"sprites/weap2.spr",1.0,50.0,0,0,0,255);

               
                if(weapons & 1<<CSW_C4)
                        drawsprite(userWeap[iPlayers[c]][6],iPlayers[c],"sprites/weap2.spr",3.0,50.0,255,0,0,255);
                else if(cs_get_user_defuse(iPlayers[c]))
                        drawsprite(userWeap[iPlayers[c]][6],iPlayers[c],"sprites/weap2.spr",4.0,50.0,255,0,0,255);
                else
                        drawsprite(userWeap[iPlayers[c]][6],iPlayers[c],"sprites/weap2.spr",3.0,50.0,0,0,0,255);

#endif
                }
        NewRound = false;
        }

drawsprite(ent,player,str[],Float:frame,Float:offset,render,r,g,b){

                if(!is_user_alive(player) || !is_user_connected(player) || cs_get_user_team(player) == CS_TEAM_SPECTATOR)
                        return;

                if (NewRound){               
                        engfunc(EngFunc_SetModel, ent, str);
                        set_pev(ent, pev_movetype, MOVETYPE_NOCLIP);
                        set_pev(ent, pev_framerate, 1.0)
                        set_pev(ent, pev_scale, 0.3)
                        }

                set_pev(ent, pev_frame, frame)
                set_rendering(ent, kRenderFxNone, r, g, b, kRenderTransAdd, render)
                pev(player, pev_origin, userOrig[player]);
                userOrig[player][2] += offset;
                set_pev(ent, pev_origin, userOrig[player]);
                }

Alguien me podria ayudar, yo no se nada o practicamente nada..

AL utilizar el amx_debug para que me de info del error OBTUVE ESTO:

Quote:

L 06/01/2020 - 01:23:52: Start of error session.
L 06/01/2020 - 01:23:52: Info (map "de_dust2") (file "addons/amxmodx/logs/error_20200601.log")
L 06/01/2020 - 01:23:52: [ENGINE] Entity 0 can not be removed
L 06/01/2020 - 01:23:52: [AMXX] Displaying debug trace (plugin "showequips.amxx", version "1.3")
L 06/01/2020 - 01:23:52: [AMXX] Run time error 10: native error (native "remove_entity")
L 06/01/2020 - 01:23:52: [AMXX] [0] showequips.sma::remove_ents (line 107)
L 06/01/2020 - 01:23:52: [AMXX] [1] showequips.sma::event_new_round (line 96)
L 06/01/2020 - 01:24:14: [ENGINE] Entity 0 can not be removed
L 06/01/2020 - 01:24:14: [AMXX] Displaying debug trace (plugin "showequips.amxx", version "1.3")
L 06/01/2020 - 01:24:14: [AMXX] Run time error 10: native error (native "remove_entity")
L 06/01/2020 - 01:24:14: [AMXX] [0] showequips.sma::remove_ents (line 107)
L 06/01/2020 - 01:24:14: [AMXX] [1] showequips.sma::event_new_round (line 96)
L 06/01/2020 - 01:24:17: [ENGINE] Entity 0 can not be removed
L 06/01/2020 - 01:24:17: [AMXX] Displaying debug trace (plugin "showequips.amxx", version "1.3")
L 06/01/2020 - 01:24:17: [AMXX] Run time error 10: native error (native "remove_entity")
L 06/01/2020 - 01:24:17: [AMXX] [0] showequips.sma::remove_ents (line 107)
L 06/01/2020 - 01:24:17: [AMXX] [1] showequips.sma::event_new_round (line 96)
L 06/01/2020 - 01:24:22: [ENGINE] Entity 0 can not be removed
L 06/01/2020 - 01:24:22: [AMXX] Displaying debug trace (plugin "showequips.amxx", version "1.3")
L 06/01/2020 - 01:24:22: [AMXX] Run time error 10: native error (native "remove_entity")
L 06/01/2020 - 01:24:22: [AMXX] [0] showequips.sma::remove_ents (line 107)
L 06/01/2020 - 01:24:22: [AMXX] [1] showequips.sma::event_new_round (line 96)
L 06/01/2020 - 01:25:05: [ENGINE] Entity 0 can not be removed
L 06/01/2020 - 01:25:05: [AMXX] Displaying debug trace (plugin "showequips.amxx", version "1.3")
L 06/01/2020 - 01:25:05: [AMXX] Run time error 10: native error (native "remove_entity")
L 06/01/2020 - 01:25:05: [AMXX] [0] showequips.sma::remove_ents (line 107)
L 06/01/2020 - 01:25:05: [AMXX] [1] showequips.sma::event_new_round (line 96)
DEBE HABER ALGUN ERROR EN ESAS LINEAS... PERO COMO LAS MODIFICO? MUCHAS GRACIAS.

CrazY. 06-02-2020 11:15

Re: Ayuda? Problema con plugin showequips
 
1 Attachment(s)
Should be working now.

This forum is English. If you need support in spanish, I suggest you to ask here instead.
https://amxmodx-es.com


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

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