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

With Time


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ho83
Senior Member
Join Date: Aug 2020
Location: iran
Old 11-24-2020 , 07:03   With Time
Reply With Quote #1

Hello every one. Whats up. well I have Problem. I want This Plugin Work With TimePlay.
PHP Code:
/*    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>
#if defined USING_SQL
#include <sqlx>
#endif

#define MESSAGE_PREFIX "AMXX"

#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 SavePointsPoint_KillPoint_HsPoint_SuicidePoint_TeamKillVIP_Cost
new g_vault
new PlayerPoints[33]

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","500"// 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")
}

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

// Load Points After Unpause The Plugin
public plugin_unpause()
{
    new 
iPlayers[32], iNum
    get_players
(iPlayersiNum)
    for(new 
ii<iNumi++)
        
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)
    
        else
            
PlayerPoints[attacker] += get_pcvar_num(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)
{
    
client_print(idprint_chat"[%s] You Have Now %d Points!"MESSAGE_PREFIXPlayerPoints[id])
}

// Check If Can Buy
public buy_vip(id)
{
    if(
is_user_admin(id))
        
client_print(idprint_chat"[%s] You Already Have VIP/ADMIN Flags!"MESSAGE_PREFIX)
        
    else
    {
        if(
PlayerPoints[id] < get_pcvar_num(VIP_Cost))
            
client_print(idprint_chat"[%s] You Need More %d Points To Can Buy VIP!"MESSAGE_PREFIXget_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(idVIP_AuthIDVIP_FLAGS_ACESSVIP_PASSWORDVIP_FLAGS_TYPEVIP_Name)
    
client_print(idprint_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(idlvlcid)
{
    if( !(
cmd_access(idlvlcid0)) )
        return 
PLUGIN_HANDLED
        
    
else
    {
        new 
iMenu menu_create("\yAdd VIP:""cmdVIPAddHandler")
        
        new 
iPlayers[32], iNumiPlayerszPlayerName[32], szUserId[32]

        
get_players(iPlayersiNum)
        for(--
iNumiNum>=0iNum--)
        {
            
iPlayer iPlayers[iNum]
            
get_user_name(iPlayerszPlayerNamecharsmax(szPlayerName))
            
formatex(szUserIdcharsmax(szUserId), "%d"get_user_userid(iPlayer))
            
menu_additem(iMenuszPlayerNameszUserId0)
        }
    
        
menu_setprop(iMenuMPROP_NUMBER_COLOR"\y")
        
menu_display(idiMenu)
    }
    
    return 
PLUGIN_HANDLED
}

public 
cmdVIPAddHandler(idiMenuiItem)
{
    if( 
iItem == MENU_EXIT )
    {
        
menu_destroy(iMenu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
szUserId[32], szPlayerName[32], iPlayeriCRAP
    menu_item_getinfo
(iMenuiItemiCRAPszUserIdcharsmax(szUserId), szPlayerNamecharsmax(szPlayerName), iPlayer)
    
    if( (
iPlayer find_player("k"str_to_num(szUserId)))  )
    {
        if(
is_user_admin(iPlayer))
            
client_print(idprint_chat"[%s] %s is already on users.ini! Go on it and edit him flags.."MESSAGE_PREFIXszPlayerName)
        
        else
        {
            new 
szAuthid[32], szAdminName[32]
            
get_user_authid(iPlayerszAuthidcharsmax(szAuthid))
            
get_user_name(idszAdminNamecharsmax(szAdminName))
            
            
AddVIP(idszAuthidVIP_FLAGS_ACESSVIP_PASSWORDVIP_FLAGS_TYPEszPlayerName)
            
client_print(iPlayerprint_chat"[%s] %s added you as VIP. Next map you are VIP."MESSAGE_PREFIXszAdminName)
            
client_print(idprint_chat"[%s] You added %s <%s> as VIP. Next map he will be VIP"MESSAGE_PREFIXszPlayerNameszAuthid)
        }
    }
    
    else
        
client_print(idprint_chat"[%s] %s seems to be disconnected."MESSAGE_PREFIXszPlayerName)
    
    
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
        client_print
(idprint_chat"[%s] You Gave %d Points To %s"MESSAGE_PREFIXamounttname)
        
client_print(tidprint_chat"[%s] %s Gave You %d Points. You Have Now %d Points"MESSAGE_PREFIXnameamount)
    }
    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
(idprint_chat"[%s] You Removed %d Points From %s"MESSAGE_PREFIXamounttname)
        
client_print(tidprint_chat"[%s] %s Removed From You %d Points. You Have Now %d Points"MESSAGE_PREFIXnameamount)
    }
    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(vaultdata255"#"" ")
    
    new 
playerpoints[32]
    
    
parse(vaultdataplayerpoints31)
    
    
PlayerPoints[id] = str_to_num(playerpoints)
}

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

    
new Handle:info SQL_MakeStdTuple()
    new 
Handle:sql SQL_Connect(infoerrnoerror127)
    
    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(configsDir63)
        
format(configsDir63"%s/users.ini"configsDir)

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

        
// Make sure steamid isn't already in file.
        
new line 0textline[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(configsDirlinetextline255len)))
        {
            if (
len == || equal(textline";"1))
                continue 
// comment line

            
parsedParams parse(textlineline_steamidSIZEline_passwordSIZEline_accessflagsSIZEline_flagsSIZE)
            
            if (
parsedParams != 4)
                continue    
// Send warning/error?
            
            
if (containi(line_flagsflags) != -&& equal(line_steamidauth))
            {
                
console_print(id"[%s] %s already exists!"MESSAGE_PREFIXauth)
                return
            }
        }

        
// If we came here, steamid doesn't exist in users.ini. Add it.
        
new linetoadd[512]
        
        if (
comment[0]==0)
        {
            
formatex(linetoadd511"^r^n^"%s^" ^"%s^" ^"%s^" ^"%s^""authpasswordaccessflagsflags)
        }
        else
        {
            
formatex(linetoadd511"^r^n^"%s^" ^"%s^" ^"%s^" ^"%s^" ; %s"authpasswordaccessflagsflagscomment)
        }
        
console_print(id"Adding:^n%s"linetoadd)

        if (!
write_file(configsDirlinetoadd))
            
console_print(id"[%s] Failed writing to %s!"MESSAGE_PREFIXconfigsDir)
#if defined USING_SQL
    
}
    
    new 
table[32]
    
    
get_cvar_string("amx_sql_table"table31)
    
    new 
Handle:query SQL_PrepareQuery(sql"SELECT * FROM `%s` WHERE (`auth` = '%s')"tableauth)

    if (!
SQL_Execute(query))
    {
        
SQL_QueryError(queryerror127)
        
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_PREFIXauth)
    } else {
        
console_print(id"Adding to database:^n^"%s^" ^"%s^" ^"%s^" ^"%s^""authpasswordaccessflagsflags)
    
        
SQL_QueryAndIgnore(sql"REPLACE INTO `%s` (`auth`, `password`, `access`, `flags`) VALUES ('%s', '%s', '%s', '%s')"tableauthpasswordaccessflagsflags)
    }
    
    
SQL_FreeHandle(query)
    
SQL_FreeHandle(sql)
    
SQL_FreeHandle(info)
#endif

If Player play For 3 week get 2000 points.Thanks
ho83 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 18:09.


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