Raised This Month: $51 Target: $400
 12% 

[Help] point system


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hannes
Member
Join Date: Sep 2010
Old 10-19-2014 , 04:17   [Help] point system
Reply With Quote #1

Hey.
I'm trying to make a "pointsystem" you get xx points for killing then shows your points instead of rank..

wen i write /points it print out "* You have Points - [v0.0.1]" and i dont know what i've done wrong etc, please help me.
Thanks in advance.

PHP Code:
/* Plugin generated by AMXX-Studio */

new const PLUGIN[] =    "Point"
new const VERSION[] =     "0.0.1"
new const AUTHOR[] =    "hannes"

#include <amxmodx>
#include <amxmisc>
#include <nvault>
#include <chatcolor>

new Points[33]
new 
XP_Kill,XP_Knife,XP_Hs,SaveXP,g_vault
new PointStart
new g_iAuthID[33][36]
new 
g_first_time[32];


public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
 
    
register_event("DeathMsg""eDeath""a"
    
    
XP_Kill=register_cvar("XP_per_kill""20")
    
XP_Hs=register_cvar("XP_hs_bonus","20")
    
XP_Knife=register_cvar("XP_knife_bonus","20")
    
g_vault nvault_open("point")
    
    
PointStart register_cvar "amx_startpoints""20" )
    
    
register_clcmd("say /points""SayPoints")
    
register_clcmd("say_team /points""SayPoints")
}
public 
eDeath(  ) 
{
    new 
attacker read_data)
    new 
headshot read_data)
    new 
clipammoweapon get_user_weapon(attacker,clip,ammo);
 
    
Points[attacker] += get_pcvar_num(XP_Kill)
 
    if(
headshot)
    
Points[attacker] += get_pcvar_num(XP_Hs)
 
    if(
weapon == CSW_KNIFE)
    
Points[attacker] += get_pcvar_num(XP_Knife)
 
    
SaveData(attacker)
}

public 
SayPoints(id)
{
    
ColorChat(idGREY"^4*^3 You have ^4%s^3 Points -^3 [^4v%s^3]"Points VERSION);
}

public 
client_authorizedid )
{
    
get_user_authid(idg_iAuthIDid ] , charsmaxg_iAuthID[] ) );
    
Load(id);    
}

public 
Load(id)
{
    static 
data[256], timestamp;
    if( 
nvault_lookup(g_vaultg_iAuthID[id], datasizeof(data) - 1timestamp) )
    {
        
LoadData(id);
    }
    else
    {
        
NewUser(id);
    }
}

public 
NewUser(id)
{
    
g_first_time[id] = 1;
    new 
start get_pcvar_num PointStart )
    
    
Points[id] = start;
}

public 
client_disconnect(id)
{
    if(
get_pcvar_num(SaveXP) == 1)
    {
 
        
SaveData(id)
    }
}
public 
SaveData(id)
{
    new 
AuthID[35]
    
get_user_authid(id,AuthID,34)
 
    new 
vaultkey[64],vaultdata[256]
    
format(vaultkey,63,"%s-Mod",AuthID)
    
format(vaultdata,255,"%i#",Points[id])
    
nvault_set(g_vault,vaultkey,vaultdata)
    return 
PLUGIN_CONTINUE
}
public 
LoadData(id)
{
    new 
AuthID[35]
    
get_user_authid(id,AuthID,34)
 
    new 
vaultkey[64],vaultdata[256]
    
format(vaultkey,63,"%s-Mod",AuthID)
    
format(vaultdata,255,"%i#",Points[id])
    
nvault_get(g_vault,vaultkey,vaultdata,255)
 
    
replace_all(vaultdata255"#"" ")
 
    new 
points[32]
 
    
parse(vaultdatapoints31)
 
    
Points[id] = str_to_num(points)
 
    return 
PLUGIN_CONTINUE

__________________
hannes is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 10-19-2014 , 05:18   Re: [Help] point system
Reply With Quote #2

You have to edit this part:
PHP Code:
public SayPoints(id)
{
    
ColorChat(idGREY"^4*^3 You have ^4%s^3 Points -^3 [^4v%s^3]"Points VERSION);

zmd94 is offline
hannes
Member
Join Date: Sep 2010
Old 10-19-2014 , 06:12   Re: [Help] point system
Reply With Quote #3

Quote:
Originally Posted by zmd94 View Post
You have to edit this part:
PHP Code:
public SayPoints(id)
{
    
ColorChat(idGREY"^4*^3 You have ^4%s^3 Points -^3 [^4v%s^3]"Points VERSION);

Im not sure how i gonna edit it
__________________
hannes is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 10-19-2014 , 06:19   Re: [Help] point system
Reply With Quote #4

Just try to change that part with this code:
PHP Code:
public SayPoints(id)
{
    
ColorChat(idGREY"^4*^3 You have ^4%d^3 Points -^3 [^4v%s^3]"Points[id] , VERSION);


Last edited by zmd94; 10-19-2014 at 06:48.
zmd94 is offline
hannes
Member
Join Date: Sep 2010
Old 10-19-2014 , 06:21   Re: [Help] point system
Reply With Quote #5

Quote:
Originally Posted by zmd94 View Post
Just try to change that part with this code:
PHP Code:
public SayPoints(id)
{
    
ColorChat(idGREY"^4*^3 You have ^4%s^3 Points -^3 [^4v%s^3]"Points[id] , VERSION);

Edit: It still does the samething

Changed
PHP Code:
public SayPoints(id)
{
    
ColorChat(idGREY"^4*^3 You have ^4%s^3 Points -^3 [^4v%s^3]"Points[id] , VERSION);

to
PHP Code:
public SayPoints(id)
{
    
ColorChat(idGREY"^4*^3 You have ^4%i^3 Points -^3 [^4v%s^3]"Points[id] , VERSION);

__________________

Last edited by hannes; 10-19-2014 at 06:32.
hannes is offline
hannes
Member
Join Date: Sep 2010
Old 10-19-2014 , 06:40   Re: [Help] point system
Reply With Quote #6

Thanks for the help!
The points wont save, i get 20 new points everytime i reconnect.
__________________
hannes is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 10-19-2014 , 06:49   Re: [Help] point system
Reply With Quote #7

So, it is solved?

By the way, I have updated the code. ;)

There are still a few things that you have forgot. Please read this tutorial on how to save using nVault: https://forums.alliedmods.net/showthread.php?t=91503

Last edited by zmd94; 10-19-2014 at 06:51.
zmd94 is offline
Decak
Senior Member
Join Date: Sep 2012
Old 10-19-2014 , 06:50   Re: [Help] point system
Reply With Quote #8

Use nVault.I will show you how when I go to computer...
Decak is offline
hannes
Member
Join Date: Sep 2010
Old 10-19-2014 , 12:53   Re: [Help] point system
Reply With Quote #9

Quote:
Originally Posted by zmd94 View Post
So, it is solved?

By the way, I have updated the code. ;)

There are still a few things that you have forgot. Please read this tutorial on how to save using nVault: https://forums.alliedmods.net/showthread.php?t=91503
Uhm, im not sure what i missed
__________________
hannes is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 10-19-2014 , 20:08   Re: [Help] point system
Reply With Quote #10

Please close your nVault.
PHP Code:
public plugin_end()
{
    
nvault_close(g_vault)


Last edited by zmd94; 10-19-2014 at 20:11.
zmd94 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 18:54.


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