AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Sprite edit (https://forums.alliedmods.net/showthread.php?t=159385)

thomp22 06-16-2011 14:25

Sprite edit
 
How could i manipulate the sprite of only a certain player, not everyones?


ie:
Code:

spr = get_user_msgid( "someSprite" );
register_message( spr, "Message_spr" );
 
   
    public Message_spr()
    {
        set_msg_arg_int( 2, ARG_BYTE, 255 );
        set_msg_arg_int( 3, ARG_BYTE, 0 );
        set_msg_arg_int( 4, ARG_BYTE, 0 );
    }


Hunter-Digital 06-16-2011 19:04

Re: Sprite edit
 
3rd input variable is the player id:
Code:

public Message_spr(msgid, dest, id)
Use that to filter players.

If it doesn't seem to work, make sure it's beeing sent to each player, print a debug message with dest and id variables (dest beeing MSG_* defines from message_const.inc)

thomp22 06-17-2011 05:02

Re: Sprite edit
 
I have no idea how this filtering works how do you make it?. I tried:

Code:

public Message_Powerup(msgid, dest, id)
    {
       
        if( id == 0 )
    {
            set_msg_arg_int( 2, ARG_BYTE, 255 );
            set_msg_arg_int( 3, ARG_BYTE, 0 );
                set_msg_arg_int( 4, ARG_BYTE, 0 );
    }
    else if( id == 1 )
    {
        set_msg_arg_int( 2, ARG_BYTE, 0 );
            set_msg_arg_int( 3, ARG_BYTE, 255 );
                set_msg_arg_int( 4, ARG_BYTE, 0 );
    }
    else
    {
        set_msg_arg_int( 2, ARG_BYTE, 0 );
            set_msg_arg_int( 3, ARG_BYTE, 0 );
                set_msg_arg_int( 4, ARG_BYTE, 0 );
    }
}


Hunter-Digital 06-17-2011 06:24

Re: Sprite edit
 
id is the player's entity from 1 to 32, 0 is the server.

You don't just hardcode the values because any player can be entity id.

You can toggle sprites on/off using a command for example:

Code:

#include <amxmodx>

new bool:g_bSpr[33]

public plugin_init()
{
    register_message(get_user_msgid("What message ??"), "msg_test")

    register_clcmd("say /test", "cmd_test")
}

public cmd_test(id)
{
    g_bSpr[id] = !g_bSpr[id] /* assign the variable to it's opossite value, if true, set false, if false, set true. */

    if(g_bSpr[id])
    {
        client_print(id, print_chat, "Toggled ON")
    }
    else
    {
        client_print(id, print_chat, "Toggled OFF")
    }
}

public msg_test(msgid, dest, id)
{
    if(g_bSpr[id])
    {
        // if toggled ON, this code executes when the message triggers for this player
    }
}

Also, get_user_msgid() gets a MESSAGE id, you can't hook sprite files.

thomp22 06-17-2011 09:55

Re: Sprite edit
 
It didn't seem to work. It doesn't identify each players but treats them in a similar fashion imo. I use pl[] bool array to see which color to show for each player. But i found out the only value that matters is pl[0] and when it is true, it changes the color for all players vice versa. I wonder what goes wrong? If pl[1] = true then it should change the color only for player1.
Ideas?

Anyway are there other methods to manipulate sprite colors and other values?
Code:


#include <amxmodx>
#include <fakemeta>
#include <amxmisc>

    #define PLUGIN  "ESF color change"
    #define VERSION "1.0"
    #define AUTHOR  "thompsoni"



   
        new gMsgPowerUp;
    new bool:pl[33]
    new i;



    public plugin_init()
    {
        register_plugin( PLUGIN, VERSION, AUTHOR );
        //register_forward( FM_EmitSound, "fw_EmitSound" );
       
    //change color cmd
    register_clcmd("say /test", "cmd_test")


        gMsgPowerUp = get_user_msgid( "Powerup" );
        register_message( gMsgPowerUp, "Message_Powerup" );

   
   
       
   
    for(i=0; i<32; i++)
    {
        pl[i] = false;
    }
   

    }
   

   
public cmd_test(id)
{
    pl[id] = !pl[id] /* assign the variable to it's opossite value, if true, set false, if false, set true. */

    if(pl[id])
    {
        client_print(id, print_chat, "Toggled ON")
    }
    else
    {
        client_print(id, print_chat, "Toggled OFF")
    }
}




    public Message_Powerup(msgid, dest, id)
    {
       
        if( pl[id] )
    {
            set_msg_arg_int( 2, ARG_BYTE, 255 );
            set_msg_arg_int( 3, ARG_BYTE, 0 );
                set_msg_arg_int( 4, ARG_BYTE, 0 );
    }
    else
    {
        set_msg_arg_int( 2, ARG_BYTE, 255 );
            set_msg_arg_int( 3, ARG_BYTE, 0 );
                set_msg_arg_int( 4, ARG_BYTE, 255 );
    }



    }


Hunter-Digital 06-17-2011 15:59

Re: Sprite edit
 
You might want to learn to indent your code... too many random spaces there.

Next, if your initial code worked, this should work too... I don't know ESF's messages so I can't help you there.

thomp22 06-18-2011 04:54

Re: Sprite edit
 
Can someone give an example how to edit sprite colors,
for example in CS if you would change the color of the smoke grenade, so that each player had a different color?

Hunter-Digital 06-18-2011 05:38

Re: Sprite edit
 
There's a plugin that changes smoke's color, if you're interested how he did it, just look into it's source.


All times are GMT -4. The time now is 23:29.

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