It is currently 22 Sep 2018 10:38






Reply to topic  [ 1 post ] 
 Adaugare comanda /give 
Author Message
Membru, skill 0
Membru, skill 0

Joined: 28 Nov 2015 23:11
Posts: 39
Location: Bistrita
Detinator Steam: Da
Detinator server CS: AK47.TERORISTII.RO
SteamID: andreas_cs16
Fond eXtream: 0
Salut! Doresc sa imi adaugati in acest plugin comanda de /give, jucatorii sa isi poata transfera intre ei punctele

| Afiseaza codul
/*   Formatright © 2013, Jhob94

Buy VIP With Points is free plugin
You can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation.

This plugin is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this Plugin Source; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/

/* CREDITS:
- AMX MOD X DEVELOPMENT TEAM
- ConnorMcLeod for optimize players menu

What you need for run this plugin?
- Maybe the question is more what you cant run. Amxbans or other type of admin manager that is from AMX MOD X plugins Base
- You should use last oficial amx version. At Moment is 1.8.2
- If new amx version is realeased, i will probably need update this plugin. So if you will update your AMXX, you should update this one too.
*/

// Uncomment for SQL version
// #define USING_SQL

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <nvault>
#include < fakemeta >
#if defined USING_SQL
#include <sqlx>
#endif
#include <colorchat>

#define MESSAGE_PREFIX "AMXX"

#define TASKID_HUD 1993

#define VIP_FLAGS_TYPE "ce" // Dont Change This
#define VIP_PASSWORD "" // Dont Change This
#define VIP_FLAGS_ACESS "t" // VIP Flags (You Can Use More Then 1 BUT You Should Use Only One)

new SavePoints, Point_Kill, Point_Hs, Point_Suicide, Point_TeamKill, VIP_Cost
new g_vault
new PlayerPoints[33]
//Sync

new SyncHudMessage;

public plugin_init() {
#if defined USING_SQL
register_plugin("Buy VIP With Points (SQL)", "0.0.4", "Jhob94")
#else
register_plugin("Buy VIP With Points", "0.0.4", "Jhob94")
#endif

register_event("DeathMsg", "eDeath", "a")

SavePoints = register_cvar("SavePoints","1") // Turn 0 To Desativate Save Points Option
Point_Kill = register_cvar("Points_kill", "1") // Points That You Get Per Normal Kill
Point_Hs = register_cvar("Points_kill_hs","2") // Points That You Get Per HS Kill
Point_Suicide = register_cvar("Points_suicide","1") // Points That You Lose Per Suicide
Point_TeamKill = register_cvar("Points_teamkill","1") // Points That You Lose Per TeamKill
VIP_Cost = register_cvar("Points_VIP_Cost","1500") // How Many Points VIP Cost?

register_concmd("amx_givepoints", "admin_give_points", ADMIN_LEVEL_A, "<user> <amount> : Give Points To Someone")
register_concmd("amx_removepoints", "admin_remove_points", ADMIN_LEVEL_A, "<user> <amount> : Remove Points From Someone")

register_clcmd("say /addvip", "cmdVIPAdd", ADMIN_RCON)
register_clcmd("say_team /addvip", "cmdVIPAdd", ADMIN_RCON)

register_clcmd("say /points", "show_points")
register_clcmd("say_team /points", "show_points")
register_clcmd("say /mypoints", "show_points")
register_clcmd("say_team /mypoints", "show_points")

register_clcmd("say /buyvip", "buy_vip")
register_clcmd("say_team /buyvip", "buy_vip")

g_vault = nvault_open("vip_points_system")

SyncHudMessage = CreateHudSyncObj( )

set_task( 1.0, "task_DisplayHud", TASKID_HUD, _, _, "b", 0 );
}

// Save Points When Pausing The Plugin
public plugin_pause()
{
new iPlayers[32], iNum
get_players(iPlayers, iNum)
for(new i; i<iNum; i++)
SaveData(iPlayers[i])
}

// Load Points After Unpause The Plugin
public plugin_unpause()
{
new iPlayers[32], iNum
get_players(iPlayers, iNum)
for(new i; i<iNum; i++)
LoadData(iPlayers[i])
}

// Load Points
public client_putinserver(id)
{
PlayerPoints[id] = 0
if(get_pcvar_num(SavePoints))
LoadData(id)
}

// Give Points When Kill Someone
public eDeath()
{
new attacker = read_data(1)
new victim = read_data(2)
new headshot = read_data(3)

if(cs_get_user_team(attacker) != cs_get_user_team(victim)) // Kill Enemie
{
if(!headshot)
PlayerPoints[attacker] += get_pcvar_num(Point_Kill)
client_print(id, print_chat, "%s Ai primt %d puncte pentru ca ai facut un kill", MESSAGE_PREFIX, Point_Kill)

else
PlayerPoints[attacker] += get_pcvar_num(Point_Hs)
client_print(id, print_chat, "%s Ai primt %d puncte pentru ca ai facut un kill", MESSAGE_PREFIX, Point_Hs)
}

else
{
if(attacker == victim) // Suicide
{
if(PlayerPoints[attacker] > get_pcvar_num(Point_Suicide))
PlayerPoints[attacker] -= get_pcvar_num(Point_Suicide)

else
PlayerPoints[attacker] = 0
}

else // Team Kill (Not necessary check if friendlyfire is enabled)
{
if(PlayerPoints[attacker] > get_pcvar_num(Point_TeamKill))
PlayerPoints[attacker] -= get_pcvar_num(Point_TeamKill)

else
PlayerPoints[attacker] = 0
}
}

show_points(attacker)

if(get_pcvar_num(SavePoints))
SaveData(attacker)
}

// Show How Many Points Player Has
public show_points(id)
{
ColorChat(id, print_chat, "^x03[%s] Acum ai %d Puncte!", MESSAGE_PREFIX, PlayerPoints[id])
}

public task_DisplayHud( )
{
static iPlayers[ 32 ];
static iPlayersNum;

get_players( iPlayers, iPlayersNum, "ch" );
if( !iPlayersNum )
return;

static id, i;
for( i = 0; i < iPlayersNum; i++ )
{
id = iPlayers[ i ];


set_hudmessage(204, 0, 0, -1.0, 0.88, _, _, _, _, _, 2);
ShowSyncHudMsg( id, SyncHudMessage, "Points: %d", PlayerPoints[id]);



}
}

public buy_vip(id)
{
if(is_user_admin(id))
client_print(id, print_chat, "[%s] You Already Have VIP/ADMIN Flags!", MESSAGE_PREFIX)

else
{
if(PlayerPoints[id] < get_pcvar_num(VIP_Cost))
client_print(id, print_chat, "[%s] You Need More %d Points To Can Buy VIP!", MESSAGE_PREFIX, get_pcvar_num(VIP_Cost) - PlayerPoints[id])

else
buying_vip(id)
}
}

// Setting User VIP If Could Bought VIP
public buying_vip(id)
{
new VIP_AuthID[35], VIP_Name[32]

get_user_authid(id,VIP_AuthID,34)
get_user_name(id,VIP_Name,31)

PlayerPoints[id] -= get_pcvar_num(VIP_Cost)
AddVIP(id, VIP_AuthID, VIP_FLAGS_ACESS, VIP_PASSWORD, VIP_FLAGS_TYPE, VIP_Name)
client_print(id, print_chat, "[%s] You Bought VIP. Next Map Your VIP is Activated!", MESSAGE_PREFIX)

if(get_pcvar_num(SavePoints))
SaveData(id)
}

// Add VIP Via Chat Command
public cmdVIPAdd(id, lvl, cid)
{
if( !(cmd_access(id, lvl, cid, 0)) )
return PLUGIN_HANDLED

else
{
new iMenu = menu_create("\yAdd VIP:", "cmdVIPAddHandler")

new iPlayers[32], iNum, iPlayer, szPlayerName[32], szUserId[32]

get_players(iPlayers, iNum)
for(--iNum; iNum>=0; iNum--)
{
iPlayer = iPlayers[iNum]
get_user_name(iPlayer, szPlayerName, charsmax(szPlayerName))
formatex(szUserId, charsmax(szUserId), "%d", get_user_userid(iPlayer))
menu_additem(iMenu, szPlayerName, szUserId, 0)
}

menu_setprop(iMenu, MPROP_NUMBER_COLOR, "\y")
menu_display(id, iMenu)
}

return PLUGIN_HANDLED
}

public cmdVIPAddHandler(id, iMenu, iItem)
{
if( iItem == MENU_EXIT )
{
menu_destroy(iMenu)
return PLUGIN_HANDLED
}

new szUserId[32], szPlayerName[32], iPlayer, iCRAP
menu_item_getinfo(iMenu, iItem, iCRAP, szUserId, charsmax(szUserId), szPlayerName, charsmax(szPlayerName), iPlayer)

if( (iPlayer = find_player("k", str_to_num(szUserId))) )
{
if(is_user_admin(iPlayer))
client_print(id, print_chat, "[%s] %s is already on users.ini! Go on it and edit him flags..", MESSAGE_PREFIX, szPlayerName)

else
{
new szAuthid[32], szAdminName[32]
get_user_authid(iPlayer, szAuthid, charsmax(szAuthid))
get_user_name(id, szAdminName, charsmax(szAdminName))

AddVIP(id, szAuthid, VIP_FLAGS_ACESS, VIP_PASSWORD, VIP_FLAGS_TYPE, szPlayerName)
client_print(iPlayer, print_chat, "[%s] %s added you as VIP. Next map you are VIP.", MESSAGE_PREFIX, szAdminName)
client_print(id, print_chat, "[%s] You added %s <%s> as VIP. Next map he will be VIP", MESSAGE_PREFIX, szPlayerName, szAuthid)
}
}

else
client_print(id, print_chat, "[%s] %s seems to be disconnected.", MESSAGE_PREFIX, szPlayerName)

menu_destroy(iMenu)
return PLUGIN_HANDLED
}

// Give Points To Someone
public admin_give_points(id,level,cid)
{
if(!cmd_access(id,level,cid,3))
return PLUGIN_HANDLED

else
{
new target[32], tid
read_argv(1,target,31)
tid = cmd_target(id,target,2)

new amountstr[10], amount
read_argv(2,amountstr,9)
amount = str_to_num(amountstr)

new name[32], tname[32]
get_user_name(id,name,31)
get_user_name(tid,tname,31)

PlayerPoints[tid] += amount
PlayerPoints[id] -= amount
client_print(id, print_chat, "[%s] You Gave %d Points To %s", MESSAGE_PREFIX, amount, tname)
client_print(tid, print_chat, "[%s] %s Gave You %d Points. You Have Now %d Points", MESSAGE_PREFIX, name, amount)
}
return PLUGIN_HANDLED
}

// Remove Points From Someone
public admin_remove_points(id,level,cid)
{
if(!cmd_access(id,level,cid,3))
return PLUGIN_HANDLED

else
{
new target[32], tid
read_argv(1,target,31)
tid = cmd_target(id,target,2)

new amountstr[10], amount
read_argv(2,amountstr,9)
amount = str_to_num(amountstr)

new name[32], tname[32]
get_user_name(id,name,31)
get_user_name(tid,tname,31)

if((PlayerPoints[tid] -= amount) < 0)
amount = PlayerPoints[tid]

PlayerPoints[tid] -= amount
client_print(id, print_chat, "[%s] You Removed %d Points From %s", MESSAGE_PREFIX, amount, tname)
client_print(tid, print_chat, "[%s] %s Removed From You %d Points. You Have Now %d Points", MESSAGE_PREFIX, name, amount)
}
return PLUGIN_HANDLED
}

// Save Points
public SaveData(id)
{
new AuthID[35]
get_user_authid(id,AuthID,34)

new vaultkey[64],vaultdata[256]
format(vaultkey,63,"%s",AuthID)
format(vaultdata,255,"%i#",PlayerPoints[id])
nvault_set(g_vault,vaultkey,vaultdata)
}

// Load Points
public LoadData(id)
{
new AuthID[35]
get_user_authid(id,AuthID,34)

new vaultkey[64],vaultdata[256]
format(vaultkey,63,"%s",AuthID)
format(vaultdata,255,"%i#",PlayerPoints[id])
nvault_get(g_vault,vaultkey,vaultdata,255)

replace_all(vaultdata, 255, "#", " ")

new playerpoints[32]

parse(vaultdata, playerpoints, 31)

PlayerPoints[id] = str_to_num(playerpoints)
}

// CREDITS TO AMX MOD X DEVELOPMENT TEAM
AddVIP(id, auth[], accessflags[], password[], flags[], comment[]="")
{
#if defined USING_SQL
new error[128], errno

new Handle:info = SQL_MakeStdTuple()
new Handle:sql = SQL_Connect(info, errno, error, 127)

if (sql == Empty_Handle)
{
server_print("[AMXX] %L", LANG_SERVER, "SQL_CANT_CON", error)
//backup to users.ini
#endif
// Make sure that the users.ini file exists.
new configsDir[64]
get_configsdir(configsDir, 63)
format(configsDir, 63, "%s/users.ini", configsDir)

if (!file_exists(configsDir))
{
console_print(id, "[%s] File ^"%s^" doesn't exist.", MESSAGE_PREFIX, configsDir)
return
}

// Make sure steamid isn't already in file.
new line = 0, textline[256], len
const SIZE = 63
new line_steamid[SIZE + 1], line_password[SIZE + 1], line_accessflags[SIZE + 1], line_flags[SIZE + 1], parsedParams

// <name|ip|steamid> <password> <access flags> <account flags>
while ((line = read_file(configsDir, line, textline, 255, len)))
{
if (len == 0 || equal(textline, ";", 1))
continue // comment line

parsedParams = parse(textline, line_steamid, SIZE, line_password, SIZE, line_accessflags, SIZE, line_flags, SIZE)

if (parsedParams != 4)
continue // Send warning/error?

if (containi(line_flags, flags) != -1 && equal(line_steamid, auth))
{
console_print(id, "[%s] %s already exists!", MESSAGE_PREFIX, auth)
return
}
}

// If we came here, steamid doesn't exist in users.ini. Add it.
new linetoadd[512]

if (comment[0]==0)
{
formatex(linetoadd, 511, "^r^n^"%s^" ^"%s^" ^"%s^" ^"%s^"", auth, password, accessflags, flags)
}
else
{
formatex(linetoadd, 511, "^r^n^"%s^" ^"%s^" ^"%s^" ^"%s^" ; %s", auth, password, accessflags, flags, comment)
}
console_print(id, "Adding:^n%s", linetoadd)

if (!write_file(configsDir, linetoadd))
console_print(id, "[%s] Failed writing to %s!", MESSAGE_PREFIX, configsDir)
#if defined USING_SQL
}

new table[32]

get_cvar_string("amx_sql_table", table, 31)

new Handle:query = SQL_PrepareQuery(sql, "SELECT * FROM `%s` WHERE (`auth` = '%s')", table, auth)

if (!SQL_Execute(query))
{
SQL_QueryError(query, error, 127)
server_print("[AMXX] %L", LANG_SERVER, "SQL_CANT_LOAD_ADMINS", error)
console_print(id, "[AMXX] %L", LANG_SERVER, "SQL_CANT_LOAD_ADMINS", error)
} else if (SQL_NumResults(query)) {
console_print(id, "[%s] %s already exists!", MESSAGE_PREFIX, auth)
} else {
console_print(id, "Adding to database:^n^"%s^" ^"%s^" ^"%s^" ^"%s^"", auth, password, accessflags, flags)

SQL_QueryAndIgnore(sql, "REPLACE INTO `%s` (`auth`, `password`, `access`, `flags`) VALUES ('%s', '%s', '%s', '%s')", table, auth, password, accessflags, flags)
}

SQL_FreeHandle(query)
SQL_FreeHandle(sql)
SQL_FreeHandle(info)
#endif
}

_________________
<a href="https://www.gametracker.com/server_info/89.34.92.156:27015/" target="_blank"><img src="https://cache.gametracker.com/server_info/89.34.92.156:27015/b_560_95_1.png" border="0" width="560" height="95" alt=""/></a>


15 Sep 2018 12:48
Profile multumesc YIM WWW
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 31 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  

În cazul în care aveți probleme cu contul trimiteți un email sau mesaj la servicii_extream[arond]yahoo[punct]com

Powered by phpBB® Forum Software © phpBB Group