Hi, I'm trying to make plugin which count a player time and give him points for it but my code doesn't work i try to getTime() in client post admin check and in disconect here is my code what I do wrong (log file doesn't work too)
Code:
#include <sourcemod>
#include <sdktools>
#define PLUGIN_VERSION "1.0"
new Handle:sm_pgr_time_for_point = INVALID_HANDLE
new Handle:sm_pgr_bonus_flag = INVALID_HANDLE
new Handle:sm_pgr_bonus_rate = INVALID_HANDLE
new Handle:sm_pgr_name_pattern = INVALID_HANDLE
new userPoints[128];
new userRest[128];
new userConnect[128];
new userDisconnect[128];
public Plugin:myinfo =
{
name = "Player GameTime Rank",
author = "G[o]Q",
description = "Points for played time",
version = PLUGIN_VERSION,
url = "amxx.pl"
}
public OnPluginStart(){
CreateConVar("sm_pgr_version", PLUGIN_VERSION, "Player GameTime Rank Version", FCVAR_PLUGIN | FCVAR_SPONLY | FCVAR_NOTIFY | FCVAR_DONTRECORD);
RegConsoleCmd("sm_mypoints", Command_MyPoints, "gets your points for time spend on server")
sm_pgr_time_for_point = CreateConVar("sm_pgr_time_for_point", "1", "Flag to give bonus points", FCVAR_NOTIFY);
sm_pgr_bonus_flag = CreateConVar("sm_pgr_bonus_flag", "c", "Flag to give bonus points", FCVAR_NOTIFY);
sm_pgr_bonus_rate = CreateConVar("sm_pgr_bonus_rate", "2", "Multiplier points for bonus flag", FCVAR_NOTIFY);
sm_pgr_name_pattern = CreateConVar("sm_pgr_name_pattern", "lololo", "Pattern to give points");
LoadTranslations("common.phrases");
AutoExecConfig(true, "plugin.ptt")
}
public OnClientPostAdminCheck(client){
new String:clientName[128];
if (IsFakeClient(client)){
return
}
GetClientName(client, clientName, sizeof(clientName));
if(isClientNameOk(clientName)){
loadData(client);
}
}
public OnClientDisconnect(client){
if (IsFakeClient(client)){
return
}
saveData(client);
}
public isClientNameOk(String:clientName[]){
decl String:cvar_pattern[3];
GetConVarString(sm_pgr_name_pattern, cvar_pattern, sizeof(cvar_pattern));
return StrContains(clientName,cvar_pattern) != -1;
}
public OnClientPutInServer( client){
LogToFile("loads.txt","uP %d uRest %d uCon %d",userPoints[client],userRest[client],userConnect[client]);
}
public loadData(client){
new String:clientName[128];
GetClientName(client, clientName, sizeof(clientName));
userPoints[client] = 123;
userRest[client] = 321;
userConnect[client] = GetTime();
userDisconnect[client] = -1;
LogToFile("load.txt","uP %d uRest %d uCon %d",userPoints[client],userRest[client],userConnect[client]);
}
public saveData(client){
new String:clientName[128];
GetClientName(client, clientName, sizeof(clientName));
if(!isClientNameOk(clientName)){
return;
}
userDisconnect[client] = GetTime();
new uPoints = userPoints[client];
new uTime = userDisconnect[client] - userConnect[client] + userRest[client];
new cvar_points = GetConVarInt(sm_pgr_time_for_point);
new cvar_rate = GetConVarInt(sm_pgr_bonus_rate);
new points = uTime / cvar_points;
userRest[client] = points % cvar_points;
LogToFile("save.txt","points %d uPoints %d uDis %d uTime %d uRest %d",points,uPoints,userDisconnect[client],uTime,userRest[client]);
new total = points + uPoints;
}
p
public Action:Command_MyPoints(client, args){
new currentTime = GetTime();
new uPoints = userPoints[client];
new uTime = currentTime - userConnect[client] + userRest[client];
new cvar_points = GetConVarInt(sm_pgr_time_for_point);
new cvar_rate = GetConVarInt(sm_pgr_bonus_rate);
new points = uTime / cvar_points;
if(has_user_flag(client)){points*= cvar_rate;}
new total = points + uPoints;
PrintToChat(client,"current Time %d utime %d ",currentTime,uTime);
PrintToChat(client, "\x04[PGR]\x01 Posiadasz %d punktów", total)
PrintToChat(client, "\x04[PGR]\x01 uPoints %d uTime %d cpoints %d cRate %d points %d total %d",uPoints,uTime,cvar_points,cvar_rate,points, total)
PrintToChat(client, "\x04[PGR]\x01 uConnect %d",userConnect[client]);
return Plugin_Handled;
}
here it's screen after use commands sm_mypoints (time saved after connection is 0 and playing time is <0)
http://images.akamai.steamuserconten...0E68356B71B45/