Raised This Month: $32 Target: $400
 8% 

Trying to get the total points of a player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Elitcky
AlliedModders Donor
Join Date: Jun 2016
Location: Antofagasta, Chile
Old 12-12-2019 , 20:27   Trying to get the total points of a player
Reply With Quote #1

Hello boyz

Well im just trying to get the points of a certain player...
The plugin is this one https://forums.alliedmods.net/showthread.php?p=2593559

There it says than i can use native

PHP Code:
/*********************************************************
 * Get's the number of a player's points
 *
 * @param client        The client to get the points
 * @return                The number of points        
 *********************************************************/
native int ZR_Rank_GetPoints(int client); 
I tried to use that this way

PHP Code:

native int ZR_Rank_GetPoints
(int client);

public 
Action CMD_Puntos(int clientint args)
{
    
CPrintToChat(client"{green}[%s] {default} Tienes %s puntos."PrefixZR_Rank_GetPoints(client));

But it says this IMAGE
and that 1 point is just because the last round i won 1 point... but my client has 52 total points IMAGE TOTAL

So i don't know if the plugin is not calling correctly the points, or im not getting that correct.
I just want to get the rankpoints in the mysql database for use it in a menu with restriction points.

Thanks
__________________

Last edited by Elitcky; 12-12-2019 at 20:31.
Elitcky is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 12-13-2019 , 06:45   Re: Trying to get the total points of a player
Reply With Quote #2

PHP Code:
#include <sourcemod>
#include <zr_rank>

public Action CMD_Puntos(int clientint args)
{
    
CPrintToChat(client"{green}[%s] {default} Tienes %s puntos."PrefixZR_Rank_GetPoints(client));

__________________
Ilusion9 is offline
Elitcky
AlliedModders Donor
Join Date: Jun 2016
Location: Antofagasta, Chile
Old 12-13-2019 , 10:59   Re: Trying to get the total points of a player
Reply With Quote #3

Quote:
Originally Posted by Ilusion9 View Post
PHP Code:
#include <sourcemod>
#include <zr_rank>

public Action CMD_Puntos(int clientint args)
{
    
CPrintToChat(client"{green}[%s] {default} Tienes %s puntos."PrefixZR_Rank_GetPoints(client));

Actually i did it that way 5 min later when i posted that.
But it keeps showing me different valor in the points.

Now when i write !test1 it says IMAGE

In the Mysql DB i have 57 points, but i don't know why it only gets 9 points.
The 9 points are counting just since i installed the secondary plugin, but i want to get the total 57 points.
__________________
Elitcky is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 12-13-2019 , 15:41   Re: Trying to get the total points of a player
Reply With Quote #4

Quote:
Originally Posted by Elitcky View Post
Actually i did it that way 5 min later when i posted that.
But it keeps showing me different valor in the points.
It's the only way to call a native function from another plugin. Maybe there's something wrong with that rank plugin.
__________________
Ilusion9 is offline
Balimbanana
Member
Join Date: Jan 2017
Old 12-13-2019 , 15:51   Re: Trying to get the total points of a player
Reply With Quote #5

Maybe that function is using a different database table?
It could also be that it needs to be %i instead of %s for the points, as SourceMod will convert integers to strings and give different values.
For example, having a static value set:
Code:
public Action CMD_Puntos(int client, int args)
{
	int curstat = 57;
	char curstatch[32] = "57";
	PrintToChat(client,"BothInts %i %i BothStr %s %s",curstat,curstatch,curstat,curstatch);
	return Plugin_Handled;
}
Will actually return:
BothInts 57 14133 BothStr 9 57
So returning 9 when you have 57 actually makes sense.
Balimbanana is offline
Elitcky
AlliedModders Donor
Join Date: Jun 2016
Location: Antofagasta, Chile
Old 12-13-2019 , 16:19   Re: Trying to get the total points of a player
Reply With Quote #6

well it is working right now IMAGE
Now showing correctly the points, thanks @Balimbanana

I tried to use that in a "market menu" but all the items show as itemdraw_disabled, did i make it wrong ?
PHP Code:
public Action CMD_Shop(int clientint args)
{
    
//cHECK
    
if (IsClientInGame(client) && (!IsFakeClient(client)) && IsPlayerAlive(client))
    {
        
Menu shopmenu = new Menu(MenuHandler_Shop);
        
SetMenuTitle(shopmenu"SHOP MENU V1.0 ------------");
        
        
kvtShop.Rewind();
        if (!
kvtShop.GotoFirstSubKey())
            return 
Plugin_Handled;
        
        
char ItemID[40], name[150], points[20];
        do
        {
            
kvtShop.GetSectionName(ItemIDsizeof(ItemID));
            
kvtShop.GetString("name"namesizeof(name));
            
kvtShop.GetString("points"pointssizeof(points));
            
Format(namesizeof(points), "%s| $%s"namepoints);

            if (
ZR_Rank_GetPoints(client) >= points[client])
            {
                
shopmenu.AddItem(ItemIDname);
            } 
            else
            {
                
shopmenu.AddItem(ItemIDnameITEMDRAW_DISABLED);
            }
        } while (
kvtShop.GotoNextKey());
        
        
shopmenu.Display(client0);
    }
    else if (!
IsPlayerAlive(client))
    {
        
CPrintToChat(client"{green}[%s] {default} You are not alive to open the shopping menu."Prefix);
        return 
Plugin_Handled;
    }
    
    return 
Plugin_Continue;

The config which have the "points" string is here
PHP Code:
"shop_items"
{
    
"1"
    
{
        
"name"            "Deagle[1Bullet]"
        "item"            "weapon_deagle"
        "points"        "10"
    
}
    
"2"
    
{
        
"name"            "+50 HP"
        "item"            "health"
        "value"            "50"
        "points"        "25"
    
}
    
"3"
    
{
        
"name"            "Decoy"
        "item"            "weapon_decoy"
        "points"        "35"
    
}
    
"4"
    
{
        
"name"            "He Grenade"
        "item"            "weapon_hegrenade"
        "points"        "60"
    
}
    
"5"
    
{
        
"name"            "Invisibility"
        "item"            "Invisibility"
        "points"        "80"
    
}
    
"6"
    
{
        
"name"            "Gravity 12s"
        "item"            "Gravity"
        "points"        "100"
    
}
    
"7"
    
{
        
"name"            "Velocity 10s"
        "item"            "Speed"
        "points"        "120"
    
}

Now i have 40 points, and the first item should be able to select at 10 points, but still showing the menu as disabled IMAGE2
__________________
Elitcky is offline
Balimbanana
Member
Join Date: Jan 2017
Old 12-13-2019 , 16:35   Re: Trying to get the total points of a player
Reply With Quote #7

I think it is another issue in string.
Code:
char ItemID[40], name[150], points[20];
if (ZR_Rank_GetPoints(client) >= points[client])
points[client] will select the character at the index of the client in the points string.
I think what you need is:
Code:
if (ZR_Rank_GetPoints(client) >= StringToInt(points))
Also, I think the Format(name, sizeof(points), "%s| $%s", name, points); should be sizeof(name) instead, because it will clamp the string past 20 characters with sizeof(points).
Balimbanana is offline
Elitcky
AlliedModders Donor
Join Date: Jun 2016
Location: Antofagasta, Chile
Old 12-13-2019 , 16:45   Re: Trying to get the total points of a player
Reply With Quote #8

Quote:
Originally Posted by Balimbanana View Post
I think it is another issue in string.
Code:
char ItemID[40], name[150], points[20];
if (ZR_Rank_GetPoints(client) >= points[client])
points[client] will select the character at the index of the client in the points string.
I think what you need is:
Code:
if (ZR_Rank_GetPoints(client) >= StringToInt(points))
Also, I think the Format(name, sizeof(points), "%s| $%s", name, points); should be sizeof(name) instead, because it will clamp the string past 20 characters with sizeof(points).
Thank u so much, u actually fixed it all
I will take a look making examples with the characters, thanks
__________________
Elitcky 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 19:25.


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