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

{req}Create Command


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
ApoziX
Member
Join Date: Sep 2018
Old 09-25-2018 , 15:43   {req}Create Command
Reply With Quote #1

Hello Can Some one create !givept command for me?

The Command Will Give Play Time Points to someone

Here is the script

PHP Code:
#include <sourcemod>

static String:TPPath[PLATFORM_MAX_PATH];
new 
Handle:ClientTimer[32];
static 
Minutes[32];

//INFO
public Plugin:myinfo = {
    
name "HowLong",
    
author "hlsavior",
    
description "How long have you been playing?",
    
url "www.scnggames.com"
};


//ON START
public OnPluginStart()
{
    
CreateDirectory("addons/sourcemod/data/stats"0);
    
BuildPath(Path_SMTPPathsizeof(TPPath), "data/stats/timeplayed.txt");
    
RegConsoleCmd("sm_playedtime"Command_getTime"");
    
RegConsoleCmd("sm_pt"Command_getTime"");
}

//IN SERVER
public OnClientPutInServer(client)
{
    
AltTime(client1);
    
ClientTimer[client] = (CreateTimer(60.0TimerAddclientTIMER_REPEAT))
}

//LEAVE SERVER
public OnClientDisconnect(client)
{
    
CloseHandle(ClientTimer[client]);
    
AltTime(client0)
}

//TIMER
public Action:TimerAdd(Handle:timerany:client)
{
    if(
IsClientConnected(client) && IsClientInGame(client))
    {
        
Minutes[client]++;
    }
}

//COMMAND
public Action:Command_getTime(clientargs)
{
    
PrintToChat(client"[FZG] \x05You have played on this server for \x03%d\x05 minutes!"Minutes[client])
    return 
Plugin_Handled;
}  

//CHANGE
public AltTime(clientconnection)
{
    new 
Handle:DB CreateKeyValues("TimePlayed");
    
FileToKeyValues(DBTPPath);
    
    new 
String:SID[32];
    
GetClientAuthString(clientSIDsizeof(SID));
    
    if(
connection == 1)
    {
        
//Connected
        
if(KvJumpToKey(DBSIDtrue))
        {
            new 
String:name[MAX_NAME_LENGTH], String:temp_name[MAX_NAME_LENGTH];
            
GetClientName(clientnamesizeof(name));
            
            
KvGetString(DB"name"temp_namesizeof(temp_name), "NULL");
            
            
Minutes[client] = KvGetNum(DB"minutes"0);
        
            
KvSetNum(DB"minutes"Minutes[client])
        }
    }else if(
connection == 0)
    {
        
//Not Connected
        
if(KvJumpToKey(DBSIDtrue))
        {
            
KvSetNum(DB"minutes"Minutes[client]);
        }
    }
    
    
KvRewind(DB);
    
KeyValuesToFile(DBTPPath);
    
CloseHandle(DB);

Thanks for Helpers +rep
__________________
Looking To Start A TF2 Community
My Discord | My Steam

Last edited by ApoziX; 09-25-2018 at 16:47.
ApoziX is offline
 



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 04:39.


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