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

Help with native


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PawnBegg
Junior Member
Join Date: Apr 2022
Old 04-11-2022 , 15:18   Help with native
Reply With Quote #1

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 ?

Last edited by PawnBegg; 04-12-2022 at 05:04.
PawnBegg is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-11-2022 , 23:09   Re: Help with native
Reply With Quote #2

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.
__________________
fysiks is offline
PawnBegg
Junior Member
Join Date: Apr 2022
Old 04-12-2022 , 02:31   Re: Help with native
Reply With Quote #3

"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));

Last edited by PawnBegg; 04-12-2022 at 02:33.
PawnBegg is offline
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 04-12-2022 , 03:37   Re: Help with native
Reply With Quote #4

Quote:
Originally Posted by PawnBegg View Post
"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
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
PawnBegg
Junior Member
Join Date: Apr 2022
Old 04-12-2022 , 05:04   Re: Help with native
Reply With Quote #5

Quote:
Originally Posted by Shadows Adi View Post
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
PawnBegg is offline
Jan135
BANNED
Join Date: Feb 2022
Old 04-19-2022 , 09:29   Re: Help with native
Reply With Quote #6

That also helps me: Thank you! I'm not a developer, but modding sure does require being one.
Jan135 is offline
PawnBegg
Junior Member
Join Date: Apr 2022
Old 04-19-2022 , 10:20   Re: Help with native
Reply With Quote #7

Quote:
Originally Posted by Shadows Adi View Post
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;
}

Last edited by PawnBegg; 04-19-2022 at 10:27.
PawnBegg is offline
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 04-19-2022 , 13:46   Re: Help with native
Reply With Quote #8

Quote:
Originally Posted by PawnBegg View Post
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.
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
PawnBegg
Junior Member
Join Date: Apr 2022
Old 04-19-2022 , 14:24   Re: Help with native
Reply With Quote #9

Quote:
Originally Posted by Shadows Adi View Post
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);
PawnBegg is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 04-19-2022 , 14:44   Re: Help with native
Reply With Quote #10

Quote:
Originally Posted by PawnBegg View Post
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);
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache 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 13:39.


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