Raised This Month: $51 Target: $400
 12% 

Problem with pointers c++ amxx


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
capostrike93
Veteran Member
Join Date: Feb 2009
Location: adios y??
Old 12-26-2010 , 07:33   Problem with pointers c++ amxx
Reply With Quote #1

I can`t write into the memory my code is:

PHP Code:
// Amxmod...
static cell AMX_NATIVE_CALL read_sayparty(AMX *amxcell *params)
{
    
int id params[1];
    if(
in_party[id-1]>=0)
    {
        
CPluginMngr::CPlugin *plugin g_plugins.findPlugin(zombie_id);
        
int func;
        if (
amx_FindPublic(plugin->getAMX(), "writeMessage", &func) == AMX_ERR_NONE)
        {
            
register celldest;
            
            
int *send = &func;
            
dest = (cell *)(amx->base + (int)(((AMX_HEADER *)amx->base)->dat params[2]));
            *
dest++ = (cell)*send;
            *
dest 0;

            
send = &plr_party[in_party[id-1]][0];
            
dest = (cell *)(amx->base + (int)(((AMX_HEADER *)amx->base)->dat params[3]));
            *
dest++ = (cell)*send;
            *
dest 0;
            
            
send = &plr_party[in_party[id-1]][1];
            
dest = (cell *)(amx->base + (int)(((AMX_HEADER *)amx->base)->dat params[4]));
            *
dest++ = (cell)*send;
            *
dest 0;
            
            
send = &plr_party[in_party[id-1]][2];
            
dest = (cell *)(amx->base + (int)(((AMX_HEADER *)amx->base)->dat params[5]));
            *
dest++ = (cell)*send;
            *
dest 0;
    
            
send = &plr_party[in_party[id-1]][3];
            
dest = (cell *)(amx->base + (int)(((AMX_HEADER *)amx->base)->dat params[6]));
            *
dest++ = (cell)*send;
            *
dest 0;
            
            
send = &plr_party[in_party[id-1]][4];
            
dest = (cell *)(amx->base + (int)(((AMX_HEADER *)amx->base)->dat params[7]));
            *
dest++ = (cell)*send;
            *
dest 0;

            return 
1;
        }
    }
    return 
0;
};

//Plugin amx..
register_clcmd("say_team""say_party");

public 
say_party(id)
{
    
client_print(0,print_chat,"%d",id);
    
    static 
message[192],func,plr_owner,plr2,plr3,plr4,plr5,final_msg[250],name[32];
    
read_args(messagesizeof(message) - 1);
    
remove_quotes(message);
    
trim(message);
    
    if( !
message[0] ) return PLUGIN_CONTINUE;
    
    
client_print(0,print_chat,"%d,%d,%d,%d,%d,%d,%d",id,func,plr_owner,plr2,plr3,plr4,plr5);
    
    if(!
read_sayparty(id,func,plr_owner,plr2,plr3,plr4,plr5)) return PLUGIN_HANDLED;
    
    
client_print(0,print_chat,"%d,%d,%d,%d,%d,%d,%d",id,func,plr_owner,plr2,plr3,plr4,plr5);
    
    new 
plr[5],count;
    
get_user_name(id,name,charsof(name));
        
    if(
id == plr_ownerformatex(final_msgcharsof(final_msg), "[Party-Chat]-[Lider] ^x03%s^x04: ^x01%s"namemessage);
    else 
formatex(final_msgcharsof(final_msg), "[Party-Chat]-[Invitado] ^x03%s^x04: ^x01%s"namemessage);
    
    if(
33 plr_owner && is_user_connected(plr_owner)) plr[count++] = plr_owner;
    if(
33 plr2 && is_user_connected(plr2)) plr[count++] = plr2;
    if(
33 plr3 && is_user_connected(plr3)) plr[count++] = plr3;
    if(
33 plr4 && is_user_connected(plr4)) plr[count++] = plr4;
    if(
33 plr5 && is_user_connected(plr5)) plr[count++] = plr5;
    
    for(new 
i;i<count;i++)
    {
        if(
is_user_connected(plr[i]))
        {
            
callfunc_begin_ifuncget_zombieid() );
            
callfunc_push_int(plr[i])
            
callfunc_push_str(final_msg)
            
callfunc_end()
        }
    }
    return 
PLUGIN_HANDLED;

Always print:
1
1,0,0,0,0,0,0
1,0,0,0,0,0,0



can help me?
__________________
capostrike93 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 12-26-2010 , 20:37   Re: Problem with pointers c++ amxx
Reply With Quote #2

Try something like this:
PHP Code:
// Amxmod...
static cell AMX_NATIVE_CALL read_sayparty(AMX *amxcell *params)
{
    
int id params[1];
    if(
in_party[id-1]>=0)
    {
        
CPluginMngr::CPlugin *plugin g_plugins.findPlugin(zombie_id);
        
int func;
        if (
amx_FindPublic(plugin->getAMX(), "writeMessage", &func) == AMX_ERR_NONE)
        {
            
register celldest;
            
int *send = &func;
            
dest get_amxaddr(amxparams[2]);
            *(
dest++) = (cell)*send;

            
send = &plr_party[in_party[id-1]][0];
            
dest get_amxaddr(amxparams[3]);
            *(
dest++) = (cell)*send;
            
            
send = &plr_party[in_party[id-1]][1];
            
dest get_amxaddr(amxparams[4]);
            *(
dest++) = (cell)*send;
            
            
send = &plr_party[in_party[id-1]][2];
            
dest get_amxaddr(amxparams[5]);
            *(
dest++) = (cell)*send;
    
            
send = &plr_party[in_party[id-1]][3];
            
dest get_amxaddr(amxparams[6]);
            *(
dest++) = (cell)*send;
            
            
send = &plr_party[in_party[id-1]][4];
            
dest get_amxaddr(amxparams[7]);
            *(
dest++) = (cell)*send;

            return 
1;
        }
    }
    return 
0;
}; 
Also, make sure native is like this:
Code:
native read_sayparty(id,&func,&plr_owner,&plr2,&plr3,&plr4,&plr5);
That just means make sure that the parameters 2-7 in the native declaration are by-ref.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
capostrike93
Veteran Member
Join Date: Feb 2009
Location: adios y??
Old 12-27-2010 , 02:16   Re: Problem with pointers c++ amxx
Reply With Quote #3

loool, this deserves a huge , I forgot to define the pointers in the inc .. thanks you

the code was always right ..


Quote:
get_amxaddr(amx, params[7]);
is the same shit than
(cell *)(amx->base + (int)(((AMX_HEADER *)amx->base)->dat + params[7]));
...
__________________
capostrike93 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 12-27-2010 , 04:28   Re: Problem with pointers c++ amxx
Reply With Quote #4

I didn't know what your code was, but I knew that get_amxaddr() worked so I knew that my code would work.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply


Thread Tools
Display Modes

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 10:19.


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