AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Some nvault problem. (https://forums.alliedmods.net/showthread.php?t=163681)

GarbageBox 08-02-2011 06:04

Some nvault problem.
 
Hello everyone, I got few problems this time.
1. I want to know how can I get the player's current line in the nvault file and print it out with a messages.
[Prefix] You are no. X of total X.
2. How can I get the largest number of coins of the first five ppl and print it out in a MOTD?
3. Please check if any part of my code worng.
Code:

public show_coins(id)
{
        new iUserName[33];
        get_user_name(id, iUserName, 32);
       
        formatex(szKey, 31, "%s-Coins", iUserName);
        formatex(szData, 255, "%i", iUserCoins[id]);
               
        nvault_get(szVault, szKey, szData, 255);
               
        new gUserCoins[32];
               
        parse(szData, gUserCoins, 31)
       
        iUserCoins[id] = str_to_num(gUserCoins);
       
        client_print_color(id, DontChange, "%s You have %i coins.", gPrefix, iUserCoins[id]);
        return PLUGIN_HANDLED;
}

public EventTerrsWin()
{
        new iPlayers[32], iNum;
        get_players(iPlayers, iNum, "ch");

        for(new i = 0; i < iNum; i++)
        {
                if(get_user_team(iPlayers[i]) == 1)
                {
                        new iUserName[33];
                        get_user_name(iPlayers[i], iUserName, 32);
                       
                        iUserCoins[iPlayers[i]] += 1;
                       
                        client_print_color(0, DontChange, "%s %s gains 1 coin.", gPrefix, iUserName);
                       
                        formatex(szKey, 31, "%s-Coins", iUserName);
                        formatex(szData, 255, "%i", iUserCoins[iPlayers[i]]);
       
                        nvault_set(szVault, szKey, szData);
                        client_print_color(iPlayers[i], DontChange, "%s You have %i coins.", gPrefix, iUserCoins[iPlayers[i]]);
                }
        }
       
        return PLUGIN_CONTINUE;
}




Another question, can you explain the text in red means what?
Code:

public swearcheck(id)
{
        new szSaid[192]
        read_args(szSaid,191)
        new bool:found = false
        new pos, i = 0
        while ( i < g_swearsNum )
        {
        if ( (pos = containi(szSaid,g_swearsNames[i][1])) != -1 ){
                new len = g_swearsNames[i][0]
                while(len--)
                szSaid[pos++] = '*'
                found = true
                continue
        }
        ++i
        }

        if ( found ){
                new cmd[32]
                read_argv(0,cmd,31)         
                engclient_cmd(id,cmd,szSaid)   
        }
        return PLUGIN_CONTINUE
}


hornet 08-02-2011 07:52

Re: Some nvault problem.
 
To start with you need to insert the player's Steam ID into the nVault key instead of the player's name.

Next you need to get Bugsy's nVault Utility so you can read through each entry:
http://forums.alliedmods.net/showthread.php?t=139584

And then you need to go read up on how dynamic arrays work ... take a look at the notes in cellarray.inc.


All times are GMT -4. The time now is 03:22.

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