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

Solved How to create native


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wilianmaique
BANNED
Join Date: Nov 2016
Old 12-11-2016 , 09:03   How to create native
Reply With Quote #1

How do I create a native to pull the name of the person's rank ?, already tried:

public native_sp_get_user_rankname(id)
{
if (!is_user_connected(id))
return false

return xRankNames[xMyLevel[id]]
}

Plugin:

HTML Code:
#include <amxmodx>
#include <fvault>
#include <client_print_color>

#define PLUGIN "[CFK] Addon: Sistema de Patentes"
#define VERSION "1.0"
#define AUTHOR "Wilian M."

#define MAX_LEVELS 10
#define PREFIX "\r[\dCFK\r]"
#define PREFIXCHAT "!t[!gCFK!t]"

new xMyXP[33], xMyLevel[33]
new xCvarKillXp, xCvarKillXpHs, xCvarKillKnife, xCvarKillGrenade

new const xDataPatent[] = "cfk_patentes"

new xLevels[MAX_LEVELS] = 
{
500, // General
750, // Sargento
950, // Coronel
1150, // Prata
1350, // Bronze
1650, // Ouro
1850, // Platinium
2850, // Diamante
5555, // Desafiador
10000000
}

new xRankNames[MAX_LEVELS][] =
{
"Iniciante",
"General",
"Sargento",
"Coronel",
"Prata",
"Bronze",
"Ouro",
"Platinium",
"Diamante",
"Desafiador"
}

forward ars_user_logged_post(id)
native ars_is_user_logged(id)
native ars_get_user_account_name(index, login[], len)

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)

// Evento apos Morrer
register_event("DeathMsg","xDeathMsg","a")

register_clcmd("say xp", "xShowMyXp")
register_clcmd("say /xp", "xShowMyXp")

// Cvars do XP
xCvarKillXp = register_cvar("sp_exp_kill_normal", "3") // Experiencia ao matar normal
xCvarKillXpHs = register_cvar("sp_exp_kill_hs", "3") // Experiencia ao matar com HS
xCvarKillKnife = register_cvar("sp_exp_kill_knife", "3") // Experiencia ao matar com Faca
xCvarKillGrenade = register_cvar("sp_exp_kill_granada", "5") // Experiencia ao matar com Granada
}

public xShowMyXp(id) client_print_color(id, "%s !yExperiencia: !t%d!y, Minha Patente: !t%s!y.", PREFIXCHAT, xMyXP[id], native_sp_get_user_rankname(id))

public ars_user_logged_post(id) xLoadData(id)

public xSaveData(id)
{
if(!ars_is_user_logged(id) || !is_user_connected(id)) return;

new xAccount[40]; ars_get_user_account_name(id, xAccount, charsmax(xAccount))
new xData[50]

formatex(xData, charsmax(xData), "%d %d", xMyXP[id], xMyLevel[id])

fvault_set_data(xDataPatent, xAccount, xData)
}

public xLoadData(id)
{
new xAccount[40]; ars_get_user_account_name(id, xAccount, charsmax(xAccount))
new x1[15], x2[15], xData[50]

fvault_get_data(xDataPatent, xAccount, xData, charsmax(xData))
parse(xData, x1, charsmax(x1))

xMyXP[id] = str_to_num(x1)
xMyLevel[id] = str_to_num(x2)

xCheckMyLevel(id, 0)
}

public xDeathMsg()
{
new xKiller = read_data(1)
new xVictim = read_data(2)
new xHs = read_data(3)
new xUserWeapon = get_user_weapon(xKiller)

if(is_user_connected(xKiller) && is_user_alive(xKiller))
{
if(xVictim != xKiller)
{
if(!xHs)
{
xMyXP[xKiller] += get_pcvar_num(xCvarKillXp)
}
else if(xUserWeapon == CSW_KNIFE)
{
xMyXP[xKiller] += get_pcvar_num(xCvarKillKnife)
}
else if(xUserWeapon == CSW_HEGRENADE)
{
xMyXP[xKiller] += get_pcvar_num(xCvarKillGrenade)
}
else
{
xMyXP[xKiller] += get_pcvar_num(xCvarKillXpHs)
}

xCheckMyLevel(xKiller, 1)
xSaveData(xKiller)
}
}
}

public xCheckMyLevel(id, msg)
{
static xName[32]
get_user_name(id, xName, 31)

if(xMyLevel[id] < MAX_LEVELS)
{
while(xMyXP[id] >= xLevels[xMyLevel[id]])
{
xMyLevel[id]++

if(msg)
{
client_print_color(0, "%s !t%s !ySubiu de level. !gLevel: !y%d.", PREFIXCHAT, xName, xMyLevel[id])
//client_print_color(id, "%s !yVoce ganhou + 50 Coins por subir de Level.", PREFIXCHAT)
}
}
} 
}

public plugin_natives()
{
register_native("sp_get_user_rankname", "native_sp_get_user_rankname", 1)
register_native("sp_get_user_level", "native_sp_get_user_level", 1)
register_native("sp_get_user_xp", "native_sp_get_user_xp", 1)
}

public native_sp_get_user_rankname(id)
{
if (!is_user_connected(id))
return false

return xRankNames[xMyLevel[id]]
}
public native_sp_get_user_level(id) return xMyLevel[id]
public native_sp_get_user_xp(id) return xMyXP[id]

/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1046\\ f0\\ fs16 \n\\ par }
*/

Last edited by Arkshine; 11-23-2017 at 03:57.
wilianmaique is offline
Send a message via Skype™ to wilianmaique
xines
Veteran Member
Join Date: Aug 2013
Location: Denmark
Old 12-11-2016 , 09:13   Re: HELP - How to create native
Reply With Quote #2

You are posting in Sourcemod section, you should post in AMX section.
__________________
xines is offline
wilianmaique
BANNED
Join Date: Nov 2016
Old 12-11-2016 , 09:14   Re: HELP - How to create native
Reply With Quote #3

Quote:
Originally Posted by xines View Post
You are posting in Sourcemod section, you should post in AMX section.
Sorry
wilianmaique is offline
Send a message via Skype™ to wilianmaique
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 12-13-2016 , 00:11   Re: HELP - How to create native
Reply With Quote #4

Moved to AMX Scripting Help.
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 12-13-2016 , 08:30   Re: HELP - How to create native
Reply With Quote #5

You need to add this
PHP Code:
public plugin_natives ()
{
    
register_native("sp_get_user_rankname""native_sp_get_user_rankname"1)

__________________
My plugin:
Celena Luna is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 12-13-2016 , 08:56   Re: HELP - How to create native
Reply With Quote #6

Quote:
Originally Posted by Celena Luna View Post
You need to add this
PHP Code:
public plugin_natives ()
{
    
register_native("sp_get_user_rankname""native_sp_get_user_rankname"1)

Good job, genius, now open your eyes and don't comment if they are closed.
This question has already been answered in this cloned topic - https://forums.alliedmods.net/showthread.php?t=291455
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
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:49.


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