AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   msg fix (https://forums.alliedmods.net/showthread.php?t=251679)

omgdpcwtf 11-17-2014 06:57

msg fix
 
Hi, please I need a little fix, message which I had wrote will not show.

Code:

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

new gidPlayer[33]

public plugin_init() {
    register_plugin("PM", "1.0", "AMXMODX");
   
   
    register_clcmd("say /mp", "cmdtest")
    register_clcmd("PM",    "player")
}

public cmdtest(id)
{
    new menu = menu_create("For Who?", "choose")
   
    new player2, players[ 32 ], num, name[32]
    get_players( players, num, "a" )
    for ( new i = 0; i < num; i++ )
    {
        player2 = players[i]
        get_user_name(player2, name, charsmax(name))
        menu_additem(menu, name, "", 0)
    }
    menu_display(id, menu, 0)
}

public choose(id, menu, item)
{
    if( item == MENU_EXIT )
    {
        menu_destroy(menu)
        return PLUGIN_HANDLED
    }
   
    new Data[6], Name[64]
    new Access, Callback
    menu_item_getinfo(menu, item, Access, Data,5, Name, 63, Callback)
   
    new player2 = str_to_num(Data)
 
    gidPlayer[id] = player2
    client_cmd(id, "messagemode PM")
   
    menu_destroy(menu)
    return PLUGIN_HANDLED
}

public player(id)
{
    new say[300]
    read_args(say, charsmax(say))
       
    remove_quotes(say)
       
    if(!is_str_num(say) || equal(say, ""))
        return PLUGIN_HANDLED
       
    msgpm(id, say)   
   
    return PLUGIN_CONTINUE
}

msgpm(id, say[]) {
    new amount = str_to_num(say)
    new victim = gidPlayer[id]
   
    new vname[32], vname2[32]
    get_user_name(victim, vname, 31)
    get_user_name(id, vname2, 31)
       
    client_print(id , print_chat, "[PM] for player %s: %s", vname, amount);
    client_print(victim, print_chat, "[PM] from player %s: %s", vname2, amount)   

   
}


hleV 11-17-2014 07:38

Re: msg fix
 
amount is an integer, so change the last %s to %d in both strings.

omgdpcwtf 11-17-2014 07:44

Re: msg fix
 
I changed and it works! But works only for number...how transfer it to text?

YamiKaitou 11-17-2014 08:09

Re: msg fix
 
Transfer what to text? If you mean how to convert the Integer to a String, use num_to_str

Eagle07 11-17-2014 08:17

Re: msg fix
 
Your can try this it's working ^^

https://forums.alliedmods.net/showpo...4&postcount=19

omgdpcwtf 11-17-2014 08:26

Re: msg fix
 
thank you all, it works


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

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