Raised This Month: $ Target: $400
 0% 

ShowSyncHudMsg to all players with languages


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
e12harry
Member
Join Date: Apr 2010
Old 07-28-2011 , 10:54   Re: ShowSyncHudMsg to all players with languages
Reply With Quote #1

No I did not. I waned to use one function for all. I saw this kind of work in many plugins, but I dont't know results in them.
If this is normal behaviour I will format message for each player and display separately.
Will the message be formated this way than:

Code:
public showTimeVoteResults(){
    new players[32];
    new num;
    get_players(players, num, "ch");
    new result = get_pcvar_num(gCvarTimeVoteResults);
    if(get_pcvar_num(gCvarTimeVoteWin) != 2 && result == 3)
        result = 1;
        
    for(new i=0;i<num;i++)
        showTimeVoteResultsForPlayer(players[i], result);
if(!mapTimeVoteEnd){
        set_task(0.5, "showTimeVoteResults");
    }
}


public showTimeVoteResultsForPlayer(id, result) {
    new t;
    new msg[256];
    new item[32];
    
    switch(result){
        case 0: return;
        case 1:{
            for(new i=0;i<mapTimesCount;i++){
                t = mapTimes[i];
                formatex(item, charsmax(item), "%d %L [%d]^n", t, id, LANG_PLAYER, "MINUTES", mapTimesVotes[i]);
                add(msg, charsmax(msg), item);
            }
        }
        case 2: {
            new itm1 = -1, itm1count=-1, idx1, idx2, itm2=-1,itm2count=-1;
            getTop2(mapTimes, mapTimesVotes, mapTimesCount, itm1, idx1,itm1count,itm2,idx2, itm2count);
    
            formatex(item, charsmax(item), "%d %L [%d]^n", itm1, id, LANG_PLAYER, "MINUTES", itm1count);
            add(msg, charsmax(msg), item);
            formatex(item, charsmax(item), "%d %L [%d]", itm2, id, LANG_PLAYER, "MINUTES", itm2count);
            add(msg, charsmax(msg), item);
        }
        case 3:{
            new sum = 0;
            for(new i =1;i<mapTimesCount;i++){
                sum += mapTimesVotes[i] * mapTimes[i];
            }
            new num = getRealPlayersnum();
            formatex(msg, charsmax(msg), "%d %L", floatround(float(sum)/ float(num)), id,  LANG_PLAYER, "MINUTES");
        }
    }
    trim(msg);
    set_hudmessage(255, 0, 0, 0.01, 0.14, 0, 6.0, 1.0);
    ShowSyncHudMsg(id, gHudCenteredMsg,  msg);
}
Or should it be formated in other way ?
Can I use one SyncHudObject for all players?

Last edited by e12harry; 07-28-2011 at 11:05.
e12harry is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-28-2011 , 10:58   Re: ShowSyncHudMsg to all players with languages
Reply With Quote #2

Quote:
Originally Posted by e12harry View Post
No I did not. I waned to use one function for all. I saw this kind of work in many plugins, but I dont't know results in them.
If this is normal behaviour I will format message for each player and display separately.
Will the message be formated this way than:

Code:
        set_task(0.5, "showTimeVoteResults");
                formatex(item, charsmax(item), "%d %L [%d]^n", t, id, LANG_PLAYER, "MINUTES", mapTimesVotes[i]);
where id is id of player?
Or should it be formated in other way ?
Can I use one SyncHudObject for all players?
I meant to say "you have to" not just "you have".
You almost got it right, except for a few things:
- That set task I show above needs to be outside the loop.
- When formatting ML for player id, the format is: id, "KEY" (remove your LANG_PLAYER arg)
You should be able to use the same SyncHudObject for all players.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply



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 00:54.


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