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

Block keeps getting called.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 10-28-2021 , 13:01   Block keeps getting called.
Reply With Quote #1

I have this code

PHP Code:
public GetFreePoints(id)
{
    new 
szName[32], szAuth[35];
    
get_user_name(idszNamecharsmax(szName));
    
get_user_authid(idszAuthcharsmax(szAuth));

    if(!
nvault_get(g_iVaultHandleszAuthszNamecharsmax(szName)))
    {
        
hnsxp_add_user_xp(idget_pcvar_num(g_pPointsAmount));
        
nvault_set(g_iVaultHandleszAuthszName);
        
CC_SendMessage(id"You succesfully received &x03%i &x04XP&x01."get_pcvar_num(g_pPointsAmount));
    }

No matter what, that check still passes every time. Can someone explain me why, cause i'm really not getting it right now.
__________________

Last edited by Napoleon_be; 10-28-2021 at 13:03.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-28-2021 , 13:29   Re: Block keeps getting called.
Reply With Quote #2

Use nvault_lookup instead.


or you can do this, you don't have to save the name.

PHP Code:
public GetFreePoints(id)
{
    new 
szAuth[35];
    
get_user_authid(idszAuthcharsmax(szAuth));

    if(
nvault_get(g_iVaultHandleszAuth) != 1)
    {
        new 
szName[32];
        
get_user_name(idszNamecharsmax(szName));
        
hnsxp_add_user_xp(idget_pcvar_num(g_pPointsAmount));
        
nvault_set(g_iVaultHandleszAuth"1");
        
CC_SendMessage(id"You succesfully received &x03%i &x04XP&x01."get_pcvar_num(g_pPointsAmount));
    }

__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 10-28-2021 at 13:32.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 10-28-2021 , 15:49   Re: Block keeps getting called.
Reply With Quote #3

Thanks for the help, will try it.

Could u explain to me why it wasn't working as how i tried to do it?

My intention was to save the name according to the steam id. So everytime a player joins with the same steam id, but a different name, this check should still be passed.

The basic idea is to give someone points just once per name. Once their name is changed, i want the command to be available again. I don't wanna use booleans for this.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-28-2021 , 16:22   Re: Block keeps getting called.
Reply With Quote #4

Then change the key to save by name instead of steamid if you desire to give points per name.

And about the explanation you can just do debugging and see what'sthe outputs.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 10-28-2021 , 17:10   Re: Block keeps getting called.
Reply With Quote #5

Quote:
Originally Posted by Napoleon_be View Post
I have this code

No matter what, that check still passes every time. Can someone explain me why, cause i'm really not getting it right now.
http://www.amxmodx.org/api/nvault/nvault_get

Code:
Return Result as integer if only the first two arguments of the function are used.
1 if only the first three arguments are used.
String length if all four parameters are used.
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 10-28-2021 , 17:17   Re: Block keeps getting called.
Reply With Quote #6

Quote:
Originally Posted by Shadows Adi View Post
http://www.amxmodx.org/api/nvault/nvault_get

Code:
Return Result as integer if only the first two arguments of the function are used.
1 if only the first three arguments are used.
String length if all four parameters are used.
However, my first example should return a string, as explained in the wiki.

Code:
nvault_get(vaultHandle, "myKey", myString, charsmax(myString));
Quote:
Originally Posted by Natsheh View Post
Then change the key to save by name instead of steamid if you desire to give points per name.

And about the explanation you can just do debugging and see what'sthe outputs.
Yea you're right, i'll just save by name, lmao my brain these days.
__________________

Last edited by Napoleon_be; 10-28-2021 at 17:21.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 10-28-2021 , 17:37   Re: Block keeps getting called.
Reply With Quote #7

Quote:
Originally Posted by Napoleon_be View Post
However, my first example should return a string, as explained in the wiki.

Code:
nvault_get(vaultHandle, "myKey", myString, charsmax(myString));
No, in return you will get the string lenght, string is copied into the parameter passed.
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]

Last edited by Shadows Adi; 10-28-2021 at 17:37.
Shadows Adi is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 10-28-2021 , 18:07   Re: Block keeps getting called.
Reply With Quote #8

Quote:
Originally Posted by Shadows Adi View Post
No, in return you will get the string lenght, string is copied into the parameter passed.
You're right.

From what i've heard of the tester, this version should work.

PHP Code:
public GetFreePoints(id)
{
    new 
szName[MAX_NAME_LENGTH], szResult[MAX_NAME_LENGTH];
    
get_user_name(idszNamecharsmax(szName));

    
log_amx("DEBUG: Player current name: %s"szName);

    if(
nvault_get(g_iVaultHandleszNameszResultcharsmax(szResult)))
    {
        
log_amx("DEBUG: Player name was already found: %s"szResult);
        return 
PLUGIN_HANDLED;
    }

    
log_amx("DEBUG: Player name not found in nvault: %s, xp granted."szName);

    
nvault_set(g_iVaultHandleszNameszName);

    
hnsxp_add_user_xp(idget_pcvar_num(g_pPointsAmount));

    
CC_SendMessage(id"You succesfully received &x03%i &x04XP&x01."get_pcvar_num(g_pPointsAmount));

    return 
PLUGIN_HANDLED;

If anyone has suggestions on how to do it "better", always welcome.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 10-29-2021 , 18:21   Re: Block keeps getting called.
Reply With Quote #9

If this command can be used more than once, you can use the timestamp advantage nvault offers using nvault_lookup. Whenever you claim your points update its timestamp with nvault_touch.
bigdaddy424 is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 10-29-2021 , 20:53   Re: Block keeps getting called.
Reply With Quote #10

Quote:
Originally Posted by bigdaddy424 View Post
If this command can be used more than once, you can use the timestamp advantage nvault offers using nvault_lookup. Whenever you claim your points update its timestamp with nvault_touch.
Why would i do that when i only have to compare player name vs vault player name?

It's pretty simple: If name is not found in nvault, give XP. If name is found in nvault, don't give XP, cause he already got it earlier.
__________________

Last edited by Napoleon_be; 10-29-2021 at 20:55.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
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 02:30.


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