AlliedModders

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

ironskillz1 01-09-2013 12:39

menu
 
I want to see the percent of all players on the server but it doesnt work
exemple this line shows me how many percent i got
and it works great
Code:

Terroist Surviver </td><td> %i / %i  </td><td> %d%% </td></tr>", iAchLevel[i][SURVIVE],  iAchPoints[SURVIVE], 100 * iAchLevel[i][SURVIVE] /  iAchPoints[SURVIVE]);
But this line dont shows me players percent
when i open the meny it shows that i got 0% and evry body else got random percent LOL
Code:

new szMenuKey[128];
for( new i; i < iNum; i++ )
    {
        iPlayer = iPlayers[i];
        new percent = 100 * iAchLevel[i][i]/iAchPoints[i]
        get_user_name(iPlayer, szName, charsmax(szName));
        format(szMenuKey,127,"%s%s \d[%d%%]^n",(id==iPlayer)?"\r":"",szName,percent);
        num_to_str(iPlayer, szKey, charsmax(szKey));
        menu_additem(iMenu, szMenuKey, szKey);

but if i change the code to
Code:

new szMenuKey[128];
for( new i; i < iNum; i++ )
    {
        iPlayer = iPlayers[i];
        new percent = 100 * iAchLevel[id][i]/iAchPoints[i]
        get_user_name(iPlayer, szName, charsmax(szName));
        format(szMenuKey,127,"%s%s \d[%d%%]^n",(id==iPlayer)?"\r":"",szName,percent);
        num_to_str(iPlayer, szKey, charsmax(szKey));
        menu_additem(iMenu, szMenuKey, szKey);

the percent only works for guys that open the meny

and here is the array
Code:

new iAchLevel[MaxPlayers][iAchCount]
and here is a other iAchLevel line in the plugin
Code:

iAchLevel[id][JUMP]++
How can i fix so it shows evryones stats including my own in the menu?

AngeIII 01-09-2013 13:04

Re: menu
 
new percent = 100 * iAchLevel[i][i]/iAchPoints[i]
to
new percent = 100 * iAchLevel[iPlayer][ACHIEVMENT NUMBER!!!!]/iAchPoints[ACHIEVMENT NUMBER!!!]

but this is incorrect.
if you want to show HOW MANY achievments have player of all possible achievments you should
100 * allplayerachievments / totalpossibleachievmentscount.
as i know for you it is:
GlobalVariable:
iTotalAchievements = totalpossibleachievmentscount
all player achievments = TotalAchievements[Player_id]
if you want to show players achievment of selected ACHIEVMENT:
for example achievment: "SURVIVE"
player1 done: [0 %]
player2 done: [50 %]
this is:
100* iAchLevel[player id][achievement id]/iAchPoints[achievment id]

ironskillz1 01-09-2013 13:15

Re: menu
 
this code worked perfect for me :)
Code:

new percent = 100 * iAchLevel[iPlayer][i]/iAchPoints[i]
And the percent is counting your ''points'' and with points and mean how many kills/death/survive/jumps of the total points
so if the total points is 100 and you got 50 points it say [50%] Done :)

AngeIII 01-09-2013 13:25

Re: menu
 
new percent = 100 * iAchLevel[iPlayer][i]/iAchPoints[i]
with this you will get incorrect result cause "i" it is loop variable for players
so in result you will see:
first player name first achievment [player]/ first achievment total
second player name second achievment [player / second achievment total
... ..
i mean your achievment increaseas too.
so if you want to display total you should use this:
new precent = 100*TotalAchievements[iPlayer]/iTotalAchievements

ironskillz1 01-10-2013 09:21

Re: menu
 
Quote:

Originally Posted by AngeIII (Post 1870384)
new percent = 100 * iAchLevel[iPlayer][i]/iAchPoints[i]
with this you will get incorrect result cause "i" it is loop variable for players
so in result you will see:
first player name first achievment [player]/ first achievment total
second player name second achievment [player / second achievment total
... ..
i mean your achievment increaseas too.
so if you want to display total you should use this:
new precent = 100*TotalAchievements[iPlayer]/iTotalAchievements

but if i do like this
Code:

new percent = 100 * iAchLevel[iPlayer]/iAchPoints[i]
i get this error :S
Code:

Error: Array must be indexed (variable "iAchLevel") on line 404

AngeIII 01-10-2013 09:49

Re: menu
 
do what I said and don't do with "some other method".
for total:
new precent = 100*TotalAchievements[iPlayer]/iTotalAchievements


for "defined" achievement:
PHP Code:

new ach_id=JUMP// display info about JUMP achievment:
...
for ..
{
..
 new 
percent 100 iAchLevel[iPlayer][ach_id]/iAchPoints[ach_id]
...


Understand?!

ironskillz1 01-10-2013 09:59

Re: menu
 
[QUOTE=AngeIII;1870856]do what I said and don't do with "some other method".
for total:
new precent = 100*TotalAchievements[iPlayer]/iTotalAchievements


for "defined" achievement:
PHP Code:

new ach_id=JUMP// display info about JUMP achievment:
...
for ..
{
..
 new 
percent 100 iAchLevel[iPlayer][ach_id]/iAchPoints[ach_id]
...


i want the percent off the ach kills/death/survivor/jumps
like this
iAchLevel is how many kills/death/survivor/jumps you got
and iAchpoints is the total points you can get
but when i do that i get error
Code:

new percent = 100 * iAchLevel[iPlayer]/iAchPoints[i]
and the lines you sended shows how many achs you got and how many you got for 1 ach

AngeIII 01-10-2013 10:59

Re: menu
 
so you need to summup firstly.

...
PHP Code:

new szMenuKey[128];
new 
sum;
new 
sum_total;
for( new 
iiTotalAchievementsi++)
    
sum_total=sum_total+iAchPoints[i];
for( new 
iiNumi++ )
    {
        
iPlayer iPlayers[i];
        
sum=0;
        for( new 
z;z<iTotalAchievements;z++)
              
sum=sum+iAchLevel[iPlayer][z]
        new 
percent 100 sum/sum_total
        get_user_name
(iPlayerszNamecharsmax(szName));
        
format(szMenuKey,127,"%s%s \d[%d%%]^n",(id==iPlayer)?"\r":"",szName,percent);
        
num_to_str(iPlayerszKeycharsmax(szKey));
        
menu_additem(iMenuszMenuKeyszKey);
..... 


ironskillz1 01-10-2013 11:40

Re: menu
 
Nope i solved it
its works perfect with this code
Code:

new percent = 100 * iAchLevel[iPlayer][i]/iAchPoints[i]

AngeIII 01-10-2013 13:42

Re: menu
 
it is definetly wrong... variable i it is loop variable which can be from 1 to 32.
your achievments iAchPoints and iAchLevel doesn't indexed to [][33].

my method correct but I think you dont understand so good luck. when you will get errors reread :
https://forums.alliedmods.net/showpo...61&postcount=2
https://forums.alliedmods.net/showpo...56&postcount=6
https://forums.alliedmods.net/showpo...94&postcount=8


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

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