Raised This Month: $32 Target: $400
 8% 

where need to add natives?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
OriTop
New Member
Join Date: Jan 2021
Old 01-07-2021 , 04:15   where need to add natives?
Reply With Quote #1

Code:
native get_user_cash(index)
native set_user_cash(index,amount)
This mod does not work on my server because I need to add natives and I do not know where to upload for the mod to work for me, the JackPot mod is for JailBreak
Can anything help me add Natives for the mod to work on my JailBreak server?

Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fvault>

#define PLUGIN "Jailbreak Jackpot"
#define VERSION "0.2"
#define AUTHOR "eldadz"

#define PREFIX "AMXX"

enum _:enumCvar
{
	CVAR_DEPOSIT,
	CVAR_PLAYERSMIN,
	CVAR_CASHMIN,
	CVAR_CASHMAX,
	CVAR_SNIPER,
	CVAR_SNIPERNUMBER,
}
enum _:enumJackpot
{
	JACKPOT_NAME[ 33 ],
	JACKPOT_STEAM[ 35 ],
	JACKPOT_CASHJACKPOT,
	JACKPOT_CASH
}

new g_aCvar[ enumCvar ];

new g_arrayPlayer[ 33 ][ enumJackpot ];

new Array:g_aJackpot, Trie:g_trieJackpot, g_intTotal;

new Float:g_fJackpotTimer;

new const g_szJackpot[] = "jackpot_vault_v2";
new const g_szCashVault[] = "cash_vault";


public plugin_init() 
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	g_aCvar[ CVAR_DEPOSIT ] = register_cvar( "jp_deposit_min", "1000" );
	g_aCvar[ CVAR_PLAYERSMIN ] = register_cvar( "jp_players_min", "2" );
	g_aCvar[ CVAR_CASHMIN ] = register_cvar( "jp_cash_min", "50000" );
	g_aCvar[ CVAR_CASHMAX ] = register_cvar( "jp_cash_max", "100000" );
	g_aCvar[ CVAR_SNIPER ] = register_cvar( "jp_sniper", "0" );
	g_aCvar[ CVAR_SNIPERNUMBER ] = register_cvar( "jp_sniper_per", "1.5" );
	
	register_clcmd("say /jackpot", "CmdMainJackpot");
	register_clcmd("jackpot_amuont", "CmdDeposit");
	
	g_aJackpot = ArrayCreate( enumJackpot );
	g_trieJackpot = TrieCreate();
	
	CmdSetupJackpot();
}


public plugin_cfg( )
{
	g_fJackpotTimer = float( GetTime() )
	set_task( g_fJackpotTimer, "CmdActiveJackpot" )
}

public client_authorized( iClient )
{
	LoadCash( iClient );
	LoadUser( iClient );
}

public client_disconnect( iClient )
{
	SaveCash( iClient );
	SaveUser( iClient );
}
public CmdActiveJackpot()
{	
	g_fJackpotTimer = float( GetTime() )
	set_task( g_fJackpotTimer, "CmdActiveJackpot" )
	
	static data[ enumJackpot ];
	new bool:boolJackpot = CmdJacpotReady();
	
	if( boolJackpot )
	{
		new intWinner = CmdGetWinner();
		new intJackpot = CmdGetJackpotCash();
		ArrayGetArray( g_aJackpot, intWinner, data );
		
		client_print( 0, print_chat, "[ %s ] the winner is %s, he won %i$ cash %.2f%% chance.", PREFIX, data[ JACKPOT_STEAM ], intJackpot, 100 * (  float( data[ JACKPOT_CASHJACKPOT ] ) / float( intJackpot )  ));
		
		if( CmdisUserOnline(  data[ JACKPOT_STEAM ]) != -1 )
		{
			new intId = CmdisUserOnline( data[ JACKPOT_STEAM ] );
			
			g_arrayPlayer[ intId ][ JACKPOT_CASH ] += intJackpot;
			SaveCash( intId );
			
		}
		else
		{
			new strData[ 16 ];
			
			new intCash = ( data[ JACKPOT_CASH ] + intJackpot );
			formatex( strData, charsmax( strData ), "%i", intCash);
			
			fvault_set_data( g_szCashVault, data[ JACKPOT_STEAM ], strData );
		}
		
		CmdResetJackpot();
		
	}
	
}

public CmdResetJackpot()
{
	for( new i = 0; i < get_maxplayers(); i++ )		
		g_arrayPlayer[ i ][ JACKPOT_CASHJACKPOT ] = 0;
		
	g_intTotal = 0;
	fvault_clear( g_szJackpot );
	ArrayClear( g_aJackpot );
	TrieClear( g_trieJackpot );
}

public LoadCash( iClient ) 
{
	new strData[ 16 ], iNum[ 10 ];
	if( !fvault_get_data( g_szCashVault, GetUserAuthid( iClient ), strData, sizeof( strData ) - 1) ) 
	{
		g_arrayPlayer[ iClient ][ JACKPOT_CASH ] = 0;
		SaveUser( iClient );
	}
	else 
	{	
		parse( strData, iNum, charsmax( iNum ) );
		g_arrayPlayer[ iClient ][ JACKPOT_CASH ] = str_to_num( iNum );
	}
}


public SaveCash( iClient )
{
	new strData[ 16 ];
		
	formatex( strData, charsmax( strData ), "%i", g_arrayPlayer[ iClient ][ JACKPOT_CASH ] );
	fvault_set_data( g_szCashVault, g_arrayPlayer[ iClient ][ JACKPOT_STEAM ], strData );
}
public LoadUser( iClient ) 
{
	new strData[ 256 ], iNum[ 10 ];
	if( !fvault_get_data( g_szJackpot, GetUserAuthid( iClient ), strData, sizeof( strData ) - 1) ) 
	{
		copy( g_arrayPlayer[ iClient ][ JACKPOT_NAME ], charsmax(  g_arrayPlayer[][ JACKPOT_NAME ] ), GetUserName( iClient ));
		copy( g_arrayPlayer[ iClient ][ JACKPOT_STEAM ], charsmax(  g_arrayPlayer[][ JACKPOT_STEAM ] ), GetUserAuthid( iClient ));
		
		g_arrayPlayer[ iClient ][ JACKPOT_CASHJACKPOT ] = 0;
		g_arrayPlayer[ iClient ][ JACKPOT_CASH ] = 0;
		SaveUser( iClient );
	}
	else 
	{	
		copy( g_arrayPlayer[ iClient ][ JACKPOT_NAME ], charsmax(  g_arrayPlayer[][ JACKPOT_NAME ] ), GetUserName( iClient ));
		
		strbreak( strData, iNum, sizeof( iNum ), strData, sizeof( strData ) );
		g_arrayPlayer[ iClient ][ JACKPOT_CASHJACKPOT ]  = str_to_num( iNum );
	}
}

public SaveUser( iClient )
{
	new intLen, strTemp[ 256 ];
	
	intLen = format( strTemp[ intLen ], sizeof (strTemp ) - 1 - intLen , "%i", g_arrayPlayer[ iClient ][ JACKPOT_CASHJACKPOT ]);
	intLen += format( strTemp[ intLen ], sizeof (strTemp ) - 1, " ^"%s^"", g_arrayPlayer[ iClient ][ JACKPOT_NAME ]);
	
	fvault_set_data( g_szJackpot, g_arrayPlayer[ iClient ][ JACKPOT_STEAM ], strTemp );
}

public CmdSetupJackpot()
{
	static data[ enumJackpot ];
	
	new intTotal = fvault_size( g_szJackpot )
	new strData[ 256 ], intCashJackpot[ 16 ];
	
	for( new i = 0; i < intTotal; i++ )
	{
		fvault_get_keyname( g_szJackpot , i, data[ JACKPOT_STEAM ], sizeof( data[ JACKPOT_STEAM ] ) - 1);
		fvault_get_data( g_szJackpot , data[ JACKPOT_STEAM ], strData, sizeof( strData ) - 1);
		
		parse( strData, intCashJackpot, charsmax( intCashJackpot ), data[ JACKPOT_NAME ], charsmax( data[ JACKPOT_NAME ] ));
	
		data[ JACKPOT_CASHJACKPOT ] += str_to_num( intCashJackpot );
		
		if( data[ JACKPOT_CASHJACKPOT ] < 1000 )
			continue;
			
		ArrayPushArray( g_aJackpot, data );
		TrieSetCell( g_trieJackpot, data[ JACKPOT_STEAM ], g_intTotal );
		
		g_intTotal++;

	}	
}


public CmdDeposit( id )
{
	static data[ enumJackpot ];
	
	new strArgs[ 16 ];
	read_argv( id, strArgs, charsmax( strArgs ) );
	
	if( !strlen( strArgs ) || !is_str_num( strArgs ) )
	{
		client_print( id, print_chat, "[ %s ] you have to enter a vaild number", PREFIX);
		CmdMainJackpot( id )
		return PLUGIN_HANDLED;
	}
	new intDeposit = str_to_num( strArgs );
	new intMin = get_pcvar_num( g_aCvar[ CVAR_DEPOSIT ] );
	new intMax = get_pcvar_num( g_aCvar[ CVAR_CASHMAX ] );
	new intSniper = get_pcvar_num( g_aCvar[ CVAR_SNIPER ] )
	
	if( intDeposit < intMin )
	{
		client_print( id, print_chat, "[ %s ] you have to enter atleast more %i cash", PREFIX, intMin - intDeposit);
		CmdMainJackpot( id );
		return PLUGIN_HANDLED;
	}
	
	if( g_arrayPlayer[ id ][ JACKPOT_CASH ] < intDeposit )
	{
		client_print( id, print_chat, "[ %s ] you dont own this kind of cash.", PREFIX);
		CmdMainJackpot( id );
		return PLUGIN_HANDLED;
	}

	if( intSniper == 1  &&
	 intDeposit > ( CmdGetJackpotCash() * get_pcvar_float( g_aCvar[ CVAR_SNIPERNUMBER ] ) ) && 
	CmdGetJackpotCash() >= get_pcvar_num( g_aCvar[ CVAR_CASHMIN ] )  )
	{
		client_print( id, print_chat, "[ %s ] Sorry snipers not allowed, lower the bet or wait for next round.", PREFIX);
		CmdMainJackpot( id );
		return PLUGIN_HANDLED;
	}

	g_arrayPlayer[ id ][ JACKPOT_CASH ] -= intDeposit;
	g_arrayPlayer[ id ][ JACKPOT_CASHJACKPOT ] += intDeposit;
	SaveUser( id );
	
	if( TrieKeyExists( g_trieJackpot, g_arrayPlayer[ id ][ JACKPOT_STEAM ] ) )
	{
		new intKey
		TrieGetCell( g_trieJackpot, g_arrayPlayer[ id ][ JACKPOT_STEAM ], intKey );
		
		ArrayGetArray( g_aJackpot, intKey, data );
		
		data[ JACKPOT_CASHJACKPOT ] += intDeposit;
		
		ArraySetArray( g_aJackpot, intKey, data );
		
	}
	else
	{
		copy( data[ JACKPOT_STEAM ], charsmax( data[ JACKPOT_STEAM ] ), GetUserAuthid( id ) );
		copy( data[ JACKPOT_NAME ], charsmax( data[ JACKPOT_NAME ] ), GetUserName( id ) );
		
		data[ JACKPOT_CASHJACKPOT ] = intDeposit;
		
		ArrayPushArray( g_aJackpot, data );
		TrieSetCell( g_trieJackpot, data[ JACKPOT_STEAM ], g_intTotal );
		g_intTotal++
	}
	if( CmdGetJackpotCash() > intMax )
	{
		CmdActiveJackpot();
	}
	CmdMainJackpot( id );
	return PLUGIN_CONTINUE;
}

public CmdMainJackpot( id )
{
	new strTemp[ 256 ], intLen;
	new intJackpot = CmdGetJackpotCash();
	
	intLen = format( strTemp[ intLen ], sizeof( strTemp ) - 1, "\r[\w %s \r]\y Jackpot\w Main Menu^n", PREFIX);
	intLen += format( strTemp[ intLen ], sizeof( strTemp ) - 1 - intLen, "\d*Note: jackpot starts every perfect hour, or when the pool is reach over %i^n^n", get_pcvar_num( g_aCvar[ CVAR_CASHMAX ] ));
	intLen += format( strTemp[ intLen ], sizeof( strTemp ) - 1 - intLen, "\yJackpot\w Starts in: \y%s^n", CmdGetJackpotTime());
	intLen += format( strTemp[ intLen ], sizeof( strTemp ) - 1 - intLen, "\yJackpot\w Cash: \d%i\r$^n^n", intJackpot);
	intLen += format( strTemp[ intLen ], sizeof( strTemp ) - 1 - intLen, "\wYour deposited \d%i\r$\w, and your \ychances\w to win are\r %.2f%%", g_arrayPlayer[ id ][ JACKPOT_CASHJACKPOT ], 100 * ( float( g_arrayPlayer[ id ][ JACKPOT_CASHJACKPOT ] ) /  float( intJackpot )  ));
	new iMenu = menu_create(strTemp , "CmdHandlerMain");
	
	menu_additem( iMenu, "Deposit Cash", "1");
	menu_additem( iMenu, "View Jackpot Players", "2");
	
	menu_display( id, iMenu );
}

public CmdHandlerMain( id, iMenu, iKey )
{
	if( iKey == MENU_EXIT )
	{
		menu_destroy( iMenu );
	}
	else
	{
		new intKey = MenuKey( iMenu, iKey );
		switch( intKey )
		{
			case 1: client_cmd(id, "messagemode jackpot_amuont")
			case 2: CmdMenuPlayers( id );
		}
	}
}

public CmdMenuPlayers( id )
{
	static data[ enumJackpot ];
	
	new strTemp[ 128 ], intFound;
	new intJackpot = CmdGetJackpotCash();
	
	formatex( strTemp, charsmax( strTemp ), "\r[\w %s \r]\w Jackpot Menu^nViewing all players in the \yjackpot\w poll:", PREFIX);
	new iMenu = menu_create( strTemp, "CmdHandlerPlayers");
	
	for( new i = 0; i < g_intTotal; i++ )
	{
		ArrayGetArray( g_aJackpot, i, data )
		formatex( strTemp, charsmax( strTemp ), "%s \d%i\r$ \y(%.2f%%)", data[ JACKPOT_NAME ], data[ JACKPOT_CASHJACKPOT ], 100 * (  float( data[ JACKPOT_CASHJACKPOT ] ) / float( intJackpot )  ));
		menu_additem( iMenu, strTemp );
		
		intFound++;
	}
	
	if( !intFound )
	{
		menu_additem( iMenu, "\rNo Players");
	}
	
	menu_display( id, iMenu );
	
}

public CmdHandlerPlayers( id, iMenu, iKey )
{
	if( iKey == MENU_EXIT )
	{
		menu_destroy( iMenu );
		CmdMainJackpot( id );
	}
	else
	{
		CmdMenuPlayers( id );
	}
}


stock bool:CmdJacpotReady()
{
	if( CmdGetJackpotCash() < get_pcvar_num( g_aCvar[ CVAR_CASHMIN ] ) )
	{
		client_print( 0, print_chat, "[ %s ] Jackpot will be dealyed. since the pot didnt reach the minumum deposit( %i$ ).", PREFIX, get_pcvar_num( g_aCvar[ CVAR_CASHMIN ] ));
		return false;
	}
	if( g_intTotal < get_pcvar_num( g_aCvar[ CVAR_PLAYERSMIN ] ) )
	{
		client_print( 0, print_chat, "[ %s ] Jackpot will be dealyed. since no players deposited.", PREFIX);
		return false;
	}
	
	return true;
}

stock CmdGetWinner()
{
	static data[ enumJackpot ];
	
	new intCash , intRandom;
	intCash = CmdGetJackpotCash();
	intRandom = random_num( 1, intCash );
	
	new intCurrect , intPrevious, intWinner;
		
	for( new i = 0; i < g_intTotal; i++ )
	{
		ArrayGetArray( g_aJackpot, i, data );
		
		intCurrect = intPrevious + data[ JACKPOT_CASHJACKPOT ];
		
		if( intPrevious < intRandom && intRandom <=  intCurrect )
		{
			intWinner = i;
			break;
		}
		
		intPrevious += data[ JACKPOT_CASHJACKPOT ];
	}
	
	return intWinner;
	
}

stock CmdisUserOnline( strSteam[] )
{
	for( new i = 0; i < get_maxplayers(); i++ )
	{
		if( equali( strSteam, GetUserAuthid( i ) ) )
		{
			return i;
		}
	}
	return -1;
}
stock CmdGetJackpotTime()
{
	new strDate[ 64 ];
	
	new iHour, iMinute, iSecond;
	time( iHour, iMinute, iSecond )
	
	new intCheckT = iMinute;

	intCheckT = 60 - ( ( intCheckT > 0 ) ? ( iMinute + 1) : iMinute );

	formatex( strDate, charsmax( strDate ), "%i:%i", intCheckT, ( 60 - iSecond ));
	
	return strDate;
}

stock GetTime()
{
	new iHour, iMinute, iSecond;
	time( iHour, iMinute, iSecond )
	
	new intCheckT = iMinute;

	intCheckT = 60 - ( ( intCheckT > 0 ) ? ( iMinute + 1) : iMinute );
	
	return ( ( intCheckT ) * 60 ) + ( 60 - iSecond );
}

stock CmdGetJackpotCash()
{
	static data[ enumJackpot ];
	new intCash = 0;
	
	for( new i = 0; i < g_intTotal; i++ )
	{
		ArrayGetArray( g_aJackpot, i, data );
		
		intCash += data[ JACKPOT_CASHJACKPOT ];
	}
	
	return intCash;
}


stock GetUserName( const index )
{
	static strName[ 33 ];
	
	get_user_name( index, strName, charsmax( strName ) );
	
	return strName;
}

stock MenuKey(menu, item) 
{
	new szData[6], szName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, szData, charsmax(szData), szName, charsmax(szName), callback);
	
	menu_destroy(menu)
	
	return str_to_num(szData);
}

stock GetUserAuthid( const index )
{
	static strAuthid[ 35 ];
	
	get_user_authid( index, strAuthid, charsmax( strAuthid ) );
	
	return strAuthid;
}
OriTop is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-07-2021 , 22:42   Re: where need to add natives?
Reply With Quote #2

Why do you think you need to add those natives? Where did you get those natives?
__________________
fysiks is offline
Reply


Thread Tools
Display Modes

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 17:13.


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