AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help with native (https://forums.alliedmods.net/showthread.php?t=337269)

PawnBegg 04-11-2022 15:18

Help with native
 
Hello boys and girls, can some one teach me with natives, i need some help.
in .inc file i have native like this ->
Code:

/**
 * Returns a player's Rank ID. Set Rang name in output.
 *
 * @param id        Player index.
 * @param output    Output buffer for rang name.
 * @param len      Max length of a output buffer.
 *
 * @return      Player Rank ID. -1 on error.
 */
native csgor_get_user_rank(id, output[], len);

.sma
Code:

public native_get_user_rank(iPluginID, iParamNum)
{
        #if defined DEBUG
        log_to_file("csgor_debug_logs.log", "native_get_user_rank()")
        #endif

        if (iParamNum != 3)
        {
                log_error(AMX_ERR_NATIVE, "%s Invalid param num ! Valid: (PlayerID, Output, Len)", CSGO_TAG);
                return -1;
        }
       
        new id = get_param(1);
        if(!is_user_connected(id))
        {
                log_error(AMX_ERR_NATIVE, "%s Player is not connected (%d)", CSGO_TAG, id);
                return -1;
        }

        new rank = g_iUserRank[id];
        new szRank[32];
        ArrayGetString(g_aRankName, rank, szRank, charsmax(szRank));

        set_string(2, szRank, get_param(3));
        return rank;
}

how to call it in another .sma file and get rank name ?

Thanks you.

UPDATE........
i Did like this but even if my rank for ex is Silver IV i got message like this [RANK] "NAME" has connected and he is "SILVER I" rank.
Code:

    new szRank[32];
        csgor_get_user_rank(id, szRank, charsmax(szRank));
    client_print_color(0, print_chat, "^4[RANK ^3%s ^1has connected, and he is%s.", szRank);

What i did wrong? why in every connection print only SILVER I ?

fysiks 04-11-2022 23:09

Re: Help with native
 
That looks correct. Is "SILVER I" a valid rank name? Did you try printing just szRank by itself with client_print() just as a sanity check to make sure it's not happening in the client_print_color() function? Did you check the value that is returned by csgor_get_user_rank() to see if the rank ID is correct?

Add this:
Code:

client_print(0, print_chat, "Rank Name: %s (%d)", szRank, returnValueHere)
But make sure to define a new variable to store the value returned from the rank function and replace returnValueHere with that variable.

PawnBegg 04-12-2022 02:31

Re: Help with native
 
"Silver 1" is rankid- 1... When im loggin to CS:GO mod enter pw and press login then shows correctly for example my rank id - 5 it szRank print that im "Silver Elite" But if im not logged it always print "SILVER 1"
BTW error in logs
Code:

L 04/12/2022 - 00:16:19: [AMXX] Displaying debug trace (plugin "connectingmsg.amxx", version "1.0")
L 04/12/2022 - 00:16:19: [AMXX] Run time error 10: native error (native "csgor_get_user_rank")
L 04/12/2022 - 00:16:19: [AMXX]    [0] connectingmsg.sma::client_disconnected (line 24)

line 24: csgor_get_user_rank(id, szRank, charsmax(szRank));

Shadows Adi 04-12-2022 03:37

Re: Help with native
 
Quote:

Originally Posted by PawnBegg (Post 2776559)
"Silver 1" is rankid- 1... When im loggin to CS:GO mod enter pw and press login then shows correctly for example my rank id - 5 it szRank print that im "Silver Elite" But if im not logged it always print "SILVER 1"

Because player's rank is assigned after he is logged into his account:
https://github.com/ShadowsAdi/CSGORe...make.sma#L2625

If you run into any issue, you can open a ticket on project's Github. https://github.com/ShadowsAdi/CSGORemake/issues

PawnBegg 04-12-2022 05:04

Re: Help with native
 
Quote:

Originally Posted by Shadows Adi (Post 2776561)
Because player's rank is assigned after he is logged into his account:
https://github.com/ShadowsAdi/CSGORe...make.sma#L2625

If you run into any issue, you can open a ticket on project's Github. https://github.com/ShadowsAdi/CSGORemake/issues

Thanks you! SOlver

Jan135 04-19-2022 09:29

Re: Help with native
 
That also helps me: Thank you! I'm not a developer, but modding sure does require being one.

PawnBegg 04-19-2022 10:20

Re: Help with native
 
Quote:

Originally Posted by Shadows Adi (Post 2776561)
Because player's rank is assigned after he is logged into his account:
https://github.com/ShadowsAdi/CSGORe...make.sma#L2625

If you run into any issue, you can open a ticket on project's Github. https://github.com/ShadowsAdi/CSGORemake/issues

Hello, i get Rank value from database like this
Code:

rank = SQL_ReadResult(query, SQL_FieldNameToNum(query, "Rank"));
and print like this
Code:

formatex(itemName, charsmax(itemName), "%L", id, "CSGO_CLANS_APPLICATION_ITEM", userName, aplpoints, rank);
https://imgur.com/a/1EHd3rN
is it possible to convert it to string?

bcuz when im using native
Code:

csgor_get_user_rank(id, szRank, charsmax(szRank));
i just print rank of myself but i want to print another player

BTW if someone else can help me here is main plugin native
Code:

public native_get_user_rank(iPluginID, iParamNum)
{
        #if defined DEBUG
        log_to_file("csgor_debug_logs.log", "native_get_user_rank()")
        #endif

        if (iParamNum != 3)
        {
                log_error(AMX_ERR_NATIVE, "%s Invalid param num ! Valid: (PlayerID, Output, Len)", CSGO_TAG);
                return -1;
        }
       
        new id = get_param(1);
        if(!is_user_connected(id))
        {
                log_error(AMX_ERR_NATIVE, "%s Player is not connected (%d)", CSGO_TAG, id);
                return -1;
        }

        new szRank[MAX_RANK_NAME]
        new rank = -2

        if(g_bLogged[id])
        {
                rank = g_iUserRank[id];
                ArrayGetString(g_aRankName, rank, szRank, charsmax(szRank));
        }
        else
        {
                formatex(szRank, charsmax(szRank), "%L", LANG_SERVER, "CSGOR_NOT_LOGGED_CHAT")
        }

        set_string(2, szRank, get_param(3));

        return rank;
}


Shadows Adi 04-19-2022 13:46

Re: Help with native
 
Quote:

Originally Posted by PawnBegg (Post 2777217)
Hello, i get Rank value from database like this

Code:

csgor_get_user_rank(id, szRank, charsmax(szRank));
i just print rank of myself but i want to print another player

[/CODE]

You can pass the player's ID in this native and get his rank.

PawnBegg 04-19-2022 14:24

Re: Help with native
 
Quote:

Originally Posted by Shadows Adi (Post 2777238)
You can pass the player's ID in this native and get his rank.

This is not working got errors
Code:

L 04/19/2022 - 21:23:38: [CS:GO Remake] Player is not connected (6)
L 04/19/2022 - 21:23:38: [AMXX] Displaying debug trace (plugin "csgo_clans.amxx", version "2.5")
L 04/19/2022 - 21:23:38: [AMXX] Run time error 10: native error (native "csgor_get_user_rank")
L 04/19/2022 - 21:23:38: [AMXX]    [0] csgo_clans.sma::applications_menu_handle (line 1140)

Code:

        rank = SQL_ReadResult(query, SQL_FieldNameToNum(query, "Rank"));

                csgor_get_user_rank(rank, szRank, charsmax(szRank));

                formatex(itemName, charsmax(itemName), "%L", id, "CSGO_CLANS_APPLICATION_ITEM", userName, aplpoints, szRank);


Supremache 04-19-2022 14:44

Re: Help with native
 
Quote:

Originally Posted by PawnBegg (Post 2776508)
i Did like this but even if my rank for ex is Silver IV i got message like this [RANK] "NAME" has connected and he is "SILVER I" rank.
Code:

    new szRank[32];
        csgor_get_user_rank(id, szRank, charsmax(szRank));
    client_print_color(0, print_chat, "^4[RANK ^3%s ^1has connected, and he is%s.", szRank);

What i did wrong? why in every connection print only SILVER I ?

Two fields with one string variable
client_print_color(0, print_chat, "^4[RANK ^3%s ^1has connected, and he is%s.", szRank);


All times are GMT -4. The time now is 00:18.

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