AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   AddCommas to code (https://forums.alliedmods.net/showthread.php?t=342597)

Ali0mer 04-28-2023 08:06

AddCommas to code
 
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)
}


jimaway 04-28-2023 11:36

Re: AddCommas to code
 
https://forums.alliedmods.net/showpo...45&postcount=5


All times are GMT -4. The time now is 01:04.

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