Raised This Month: $ Target: $400
 0% 

AddCommas to code


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ali0mer
Senior Member
Join Date: Jan 2016
Location: Iraq
Old 04-28-2023 , 08:06   AddCommas to code
Reply With Quote #1

hello, can someone try to add commas for this code?
for example when a player type /myactive, it shows 10000 minutes, I want it to show like this 10,000
Code:
#include <amxmodx>
#include <amxmisc>
#include <colorchat>
#include <csstats>
#include <nvault>
#include <csx>

#define PLUGIN "Rank System"
#define VERSION "1.0"
#define AUTHOR "BaD CopY"

new gTime[33]
new gVault


public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    
    register_clcmd("say /myactivity", "cmd_activity")
    
    gVault = nvault_open("TIME")
}

public cmd_activity(id)
{
    new szName[33];
    
    get_user_name(id, szName, 32)
    
    new iTimeMins = gTime[id] / 60
    
    ColorChat(0, GREEN, "^4[Activity]^3 %s^1's Online Time is [Online: %i m]", szName, iTimeMins)
    
    return PLUGIN_CONTINUE;
}

public client_authorized(id)
{
    loaddata(id)
}

public client_disconnect(id)
{
    gTime[id] += get_user_time(id)
    savedata(id)
}

stock savedata(id)
{
    new AuthId[65]
    get_user_authid(id, AuthId, charsmax(AuthId))
    
    new VaultKey[64], VaultData[256]
    format(VaultKey, 63, "%s-TIME", AuthId)
    format(VaultData, 254, "%i", gTime[id])
    
    nvault_set(gVault, VaultKey, VaultData)
    
    return PLUGIN_CONTINUE
}

stock loaddata(id)
{
    new AuthID[35] 
    get_user_authid(id,AuthID,charsmax(AuthID ))
    new vaultkey[64],vaultdata[256]
    
    format(vaultkey,63,"%s-TIME" ,AuthID) 
    format(vaultdata,255,"%i",gTime[id]) 
    
    nvault_get(gVault,vaultkey,vaultdata,charsmax (vaultdata))
    
    new Time[33]
    parse(vaultdata, Time, charsmax(Time))
    
    gTime[id] = str_to_num(Time)
}

Last edited by Ali0mer; 04-28-2023 at 08:07.
Ali0mer is offline
Send a message via Skype™ to Ali0mer
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 04-28-2023 , 11:36   Re: AddCommas to code
Reply With Quote #2

https://forums.alliedmods.net/showpo...45&postcount=5
jimaway 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 15:30.


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