View Single Post
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 10-11-2020 , 05:00   Re: Money System [Bank | Donate | Give | Take | Time presents]
Reply With Quote #25

PHP Code:
num_to_str(tempidszTempid9
Use charsmax() instead, hardcoding isn't allowed.

PHP Code:
public ResetBankMenu_Hundler(idiResetBank,item)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(iResetBank)
        return 
PLUGIN_HANDLED
    
}
    new 
access,callback,data[6],iname[64]
    
    
menu_item_getinfo(iResetBank,item,access,data,5,iname,63,callback)
    
    new 
tempid str_to_num(data)
    
    
ResetBankMenu_Caller(idtempid)
    
    
menu_destroy(iResetBank)
    return 
PLUGIN_HANDLED

The first check isn't required since you already destroy the menu at the end of your function, and yet again, use charsmax() instead of hardcoding your array sizes.

PHP Code:
new iPlayers[MAX_PLAYERS], iNum 
PHP Code:
new players[32], tempidpnum
new szTempid[10]
get_players(playerspnum"ch"
Try creating arrays using the same name and method to improve the readability. Also, try to figure out yourself what you're doing wrong here... Keep using the MAX_PLAYERS define.

PHP Code:
new szInput[32
Array size could be decreased since it's very rare you'll ever get that much cash.

PHP Code:
new args[129], arg_cmd[6], cTarget[32], cMoney[10]
    
read_args(args128)
remove_quotes(args)
parse(argsarg_cmd5cTarget31cMoney9
Again, don't hardcode... It seems like you've just been copy/pasting the entire code.

PHP Code:
stock ColorChat(index, const Msg[], {FloatSqlResult,_}:...) 
{
    if (!
is_user_connected(index))
        return; 
    
    new 
Buffer[512], Buffer2[512], Prefix[32]
    
get_pcvar_string(g_pCvarPrefixPrefixcharsmax(Prefix))
    
formatex(Buffer2charsmax(Buffer2), "^x04%s ^x01%s"PrefixMsg);
    
vformat(Buffercharsmax(Buffer), Buffer23);
    
    
replace_all(Buffercharsmax(Buffer), "!g""^x04"); // Green Color
    
replace_all(Buffercharsmax(Buffer), "!n""^x01"); // Default Color
    
replace_all(Buffercharsmax(Buffer), "!t""^x03"); // Team Color
    
    
message_begin(MSG_ONE_UNRELIABLEg_iMsgSayText_index);
    
write_byte(index);
    
write_string(Buffer);
    
message_end();    
}

// color chat without prefix
stock ShowColorMessage(const id, const input[], any:...) 
{
    new 
count 1players[32];
    static 
Msg[191];
    
vformat(Msgcharsmax(Msg), input3);
    
    
replace_all(Msgcharsmax(Msg), "!g""^4"); // verde
    
replace_all(Msgcharsmax(Msg), "!n""^1"); // galben/alb/negru
    
replace_all(Msgcharsmax(Msg), "!t""^3"); // rosu/albastru/gri
    
replace_all(Msgcharsmax(Msg), "!t2""^0"); // rosu2/albastru2/gri2
    
    
if (idplayers[0] = id; else get_players(playerscount"ch");
    {
        for (new 
0counti++)
        {
            if (
is_user_connected(players[i]))
            {
                
message_begin(MSG_ONE_UNRELIABLEg_iMsgSayText_players[i]);
                
write_byte(players[i]);
                
write_string(Msg);
                
message_end();
            }
        }
    }

And yea, this doesn't make sense at all tbh... Just use OciXCrom's colorchat, or either just use the colorchat.inc for easier use. There's no need for you to create 2 stocks to seperate prefixes or not.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be