AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Does not give the corresponding frame (https://forums.alliedmods.net/showthread.php?t=326561)

wicho 08-05-2020 19:12

Does not give the corresponding frame
 
Hi everyone, well I have a menu of emotions that when I choose one a sprite appears above the player, for that I use a sprite that has 20 frames, the problem is that when I choose any emotion from the menu, the first emotion always comes out (frame 0), How can I give it the corresponding frame?? .. Thanks in advance

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <engine>
#include <fakemeta>

#define PLUGIN "Emotions Menu"
#define VERSION "1.0"
#define AUTHOR "covid"

enum 
{
         DEFAULT,
         
RED,
         
BLUE,
         
GRAY,
         
GREEN
}

enum _:EmotionsData
{
         
Name[32],
    
Frame
}

new const 
Emotions[][EmotionsData] = 
{
         { 
"Regret"},
         { 
"Scream"},
         { 
"Kiss"},
         { 
"Giggle"},
         { 
"Fall in love"},
         { 
"Perplex"},
         { 
"Angry"},
         { 
"Wink"},
         { 
"Smiling"},
         { 
"Whistles"},
         { 
"Happy"10 },
         { 
"Dissatisfied"11 },
         { 
"Sadness"12 },
         { 
"Satisfied"13 },
         { 
"Burned"14 },
         { 
"In anger"15 },
         { 
"Mocking"16 },
         { 
"Surprised"17 },
         { 
"Great..."18 },
         { 
"Afunhappy..."19 }
}

new 
g_iEnt[MAX_PLAYERS]

public 
plugin_init() 
{
         
register_plugin(PLUGINVERSIONAUTHOR)
     
         
register_clcmd("say /emotions""EmotionsMenu")
     
    
RegisterHam(Ham_Player_PostThink"player""fn_pThink"true)
}

public 
plugin_precache() 
{
         
precache_model("sprites/emotions.spr")
}

public 
client_disconnect(id)
{
    
g_iEnt[id] = 0
}

public 
client_putinserver(id)
{
    
g_iEnt[id] = 0
}
        
public 
EmotionsMenu(id)
{
         
emotions_menu(id)
}

public 
emotions_menu(id
{
         if (!
is_user_alive(id))
         {
                 
printf(id, DEFAULT, "^x04 ZP | ^x01You can't use the menu because you are not alive!")
             return 
PLUGIN_HANDLED
         
}
    
         new 
menu menu_create("\rEmotions""menu_emotions")
    new 
szBuffer[40]
    
    for (new 
0sizeof(Emotions); i++)
         {
                  
formatex(szBuffercharsmax(szBuffer), "%s"Emotions[i][Name])
                  
menu_additem(menuszBuffer)   
         }
      
         
menu_setprop(menuMPROP_EXITMEXIT_ALL)   
         
menu_display(idmenu0)
    
         return 
PLUGIN_HANDLED
}

public 
menu_emotions(idmenuitem)
{
    if (
item == MENU_EXIT)
         {
                  
menu_destroy(menu)
                  return 
PLUGIN_HANDLED
         
}
     
    if(!
is_valid_ent(g_iEnt[id]))
    {
        
g_iEnt[id] = create_entity("env_sprite")
        if(
is_valid_ent(g_iEnt[id]))
        {
                 static 
Float:flOrigin[3]
            
            
entity_get_vector(idEV_VEC_originflOrigin)
            
flOrigin[2] += 40.0
            entity_set_vector
(g_iEnt[id], EV_VEC_originflOrigin)
            
entity_set_float(g_iEnt[id], EV_FL_framerate1.0)
            
entity_set_float(g_iEnt[id], EV_FL_framefloat(Frame))
            
entity_set_float(g_iEnt[id], EV_FL_scale0.3)
            
entity_set_int(g_iEnt[id], EV_INT_movetypeMOVETYPE_NOCLIP)
            
            
engfunc(EngFunc_SetModelg_iEnt[id], "sprites/emotions.spr")
            
            
set_task(5.0"Del_Emoticon"id)
             }
    }
    
    
printf(id, DEFAULT, "^x04 ZP | ^x01You have the emotion: ^x04%s"Emotions[item][Name])
    
    return 
PLUGIN_HANDLED
}

public 
Del_Emoticon(id)
{
    
remove_entity(g_iEnt[id])
    
g_iEnt[id] = 0
}

public 
fn_pThink(id)
{
    if(
g_iEnt[id])
    {
        if(
is_valid_ent(g_iEnt[id]))
        {
            static 
Float:flOrigin[3]
            
entity_get_vector(idEV_VEC_originflOrigin)
            
flOrigin[2] += 40.0
            entity_set_vector
(g_iEnt[id], EV_VEC_originflOrigin)
        }
    }
}

stock printf(idcolor, const msg[], any:...) 
{   
         static 
Buffer[192], MsgSayTextMsgTeamInfoTeam[32]
    
         if(!
MsgSayText
    {       
                  
MsgTeamInfo get_user_msgid("TeamInfo")       
                  
MsgSayText get_user_msgid("SayText")      
         }
        
         
vformat(Buffer[1], charsmax(Buffer) - 1msg4)
    
         static const 
Teams[2][10] = 
    {
                  
"TERRORIST",
                  
"CT"
         
}

         switch (
color
    {       
                  case DEFAULT: 
        {           
                           
Buffer[0] = 0x01
                           printf_do
(idid id 33BufferMsgSayText)
                  }       
                  case 
GREEN
        {           
                           
Buffer[0] = 0x04            
                           printf_do
(idid id 33BufferMsgSayText)           
                  }       
                  case 
GRAY
        {          
                           
Buffer[0] = 0x03           
                           printf_do
(id33BufferMsgSayText)           
                  }       
                  case 
REDBLUE
        {           
                           
Buffer[0] = 0x03          
                           
if (id
            {              
                                    if (
get_user_team(idTeamcharsmax(Team)) == color
                     {                   
                                             
printf_do(ididBufferMsgSayText)                    
                                     }
                                    else 
                     {                  
                                             
printf_do(ididTeams[color-1], MsgTeamInfo)                   
                                             
printf_do(ididBufferMsgSayText)                    
                                             
printf_do(ididTeamMsgTeamInfo)
                }
                           }
                           else 
                 {           
                                    static 
Num         
                                    get_players
(TeamNum"e"Teams[color-1])
                
                                    if (
Num
                     {                    
                                             
printf_do(idTeam[0], BufferMsgSayText)
                                    }
                                    else 
                     {                  
                                             
get_players(TeamNum"h");
                    
                                             if (!
Num
                    {                       
                                                      return                       
                                              }
                    
                                             
Num Team[0]                  
                                             
get_user_team(NumTeamcharsmax(Team))
                    
                                             
printf_do(NumNumTeams[color-1], MsgTeamInfo)       
                                             
printf_do(idNumBufferMsgSayText)        
                                             
printf_do(NumNumTeamMsgTeamInfo)                   
                                    }               
                           }           
                  }       
         }
}

printf_do(idsender, const data[], MsgID
{   
         
message_begin(id MSG_ONE_UNRELIABLE MSG_BROADCASTMsgID_id)         
         
write_byte(sender)        
         
write_string(data)         
         
message_end()   



Natsheh 08-05-2020 21:13

Re: Does not give the corresponding frame
 
Replace this

float(Frame)

With :arrow:

float(Emotions[item][Frame])


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

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