Raised This Month: $ Target: $400
 0% 

[CS:S] Rank Module attempt for CS:S Timer 1.0.6


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
blacklagoon
Senior Member
Join Date: Jun 2012
Old 12-01-2012 , 04:53   [CS:S] Rank Module attempt for CS:S Timer 1.0.6
Reply With Quote #1

Hello, i'm completly noob at coding bug i tried to do it just to learn a little.
But i got many errors, and i can't find what i did wrong :s since i followed at start a tutorial for storing info and tried to do the rest alone with what i learned.
can someone help me with this ??? And explain to me what i did wrong ?
here's the timer plugin and library (by alongub) : https://forums.alliedmods.net/showthread.php?p=1747459
Sorry for my bad english :s !

Code:
#include <sourcemod>
#include <sdktools>
#include <smlib/arrays>
#include <timer>

static String:KVPath[PLATFORM_MAX_PATH];

new handle:h_pointsmap;
new handle:h_pointdifficulteasy;
new handle:h_pointdifficultnormal;
new handle:h_pointdifficulthard;
public Plugin:myinfo =
{
	name        = "[Timer] Ranking",
	author      = "Black Lagoon",
	description = "Rank players with points when they finish a map",
	version     = 1.0,
	url         = "http://commu-lagoon.com/forum/"
};

public OnPluginStart()
{
	h_pointsmap = CreateConVar("sm_pointmapdifficulty", "1", "Set difficulty of the map, 1 is easy, 2 is normal, 3 is hard", FCVAR_NOTIFY, true, 1.0, true, 3.0);
	h_pointdifficulteasy = CreateConVar("sm_pointeasy", "10", "Set point win for easy difficulty def is 10 point", FCVAR_NOTIFY);
	h_pointdifficultnormal = CreateConVar("sm_pointnormal", "50", "Set point win for normal difficulty def is 50 point", FCVAR_NOTIFY);
	h_pointdifficulthard = CreateConVar("sm_pointhard", "100", "Set point win for hard difficulty def is 100 point", FCVAR_NOTIFY);
	AutoExecConfig(true, "timerrank");
	CreateDirectory("addons/sourcemod/data/TimerRanking 3);
	BuildPath(Path_SM, KVPath, sizeof(KVPath), "data/TimerRanking/playerinfo.txt");
	
};

public OnFinishRound(client)
 {
	SavePlayerInfo(client);
 };
public SavePlayerInfo(client)
{
	new Handle:DB = CreateKeyValues("PlayersInfo");
	FileToKeyValues(DB, KVPath);
	
	new String:SteamID[32];
	
	GetClientAuthString(client, SteamId, sizeof(SteamId));
	if(KvJumpToKey(DB, SteamId, true))
		{
			new String:name[MAX_NAME_LENGHT],new String:temp_name[MAX_NAME_LENGHT];
			
			GetClientName(client, name, sizeof(name));
			
			KvGetString(DB, "name", temp_name, sizeof(temp_name), "NULL");
			
			if(GetConVarInt(h_pointsmap) == 1)
			{
				GetConVarInt(h_pointsdifficulteasy);
				h_pointsdifficulteasy = KvGetNum(DB, "points");
				KvGetNum(
			}
			if(GetConVarInt(h_pointsmap) == 2)
			{
				GetConVarInt(h_pointsdifficultnormal);
				h_pointsdifficultnormal = KvGetNum(DB, "points");
			}
			if(GetConVarInt(h_pointsmap) == 3)
			{
				GetConVarInt(h_pointsdifficulthard);
				h_pointsdifficulthard = KvGetNum(DB, "points");
			}
			new Finishedmaps = KvGetNum(DB, "Finishedmaps");
			if(StrEqual(temp_name, "NULL" && points == 0 && Finishedmaps == 0)
				{
					PrintToChatAll("[Lagoon] %s est un nouveau joueur", name);
				}
	else
		{
			PrintToChatAll("[Lagoon] %s dernière connexion sous le pseudo %s./n Et il a %d points, il a fini %d maps.", name, temp_name, points, Finishedmaps);
		}
			
			points++;
			Finishedmaps++;
			
			KvGetNum(DB, "points", points);
			KvGetNum(DB, "Finishedmaps", Finishedmaps);
			KvRewind(DB);
			CloseHandle();
		}
}

Last edited by blacklagoon; 12-01-2012 at 04:57.
blacklagoon is offline
Hunter S. Thompson
Senior Member
Join Date: Jun 2012
Old 12-02-2012 , 16:01   Re: [CS:S] Rank Module attempt for CS:S Timer 1.0.6
Reply With Quote #2

PHP Code:
#include <sourcemod>
#include <sdktools>
#include <smlib/arrays>
#include <timer>

new String:KVPath[PLATFORM_MAX_PATH];

new 
handle:h_pointsmap;
new 
handle:h_pointdifficulteasy;
new 
handle:h_pointdifficultnormal;
new 
handle:h_pointdifficulthard;
public 
Plugin:myinfo =
{
    
name        "[Timer] Ranking",
    
author      "Black Lagoon",
    
description "Rank players with points when they finish a map",
    
version     1.0,
    
url         "http://commu-lagoon.com/forum/"
};

public 
OnPluginStart()
{
    
h_pointsmap CreateConVar("sm_pointmapdifficulty""1""Set difficulty of the map, 1 is easy, 2 is normal, 3 is hard"FCVAR_NOTIFYtrue1.0true3.0);
    
h_pointdifficulteasy CreateConVar("sm_pointeasy""10""Set point win for easy difficulty def is 10 point"FCVAR_NOTIFY);
    
h_pointdifficultnormal CreateConVar("sm_pointnormal""50""Set point win for normal difficulty def is 50 point"FCVAR_NOTIFY);
    
h_pointdifficulthard CreateConVar("sm_pointhard""100""Set point win for hard difficulty def is 100 point"FCVAR_NOTIFY);
    
AutoExecConfig(true"timerrank");
    
CreateDirectory("addons/sourcemod/data/TimerRanking",  3);
    
BuildPath(Path_SMKVPathsizeof(KVPath), "data/TimerRanking/playerinfo.txt");
    
HookEvent("round_end"OnFinishRound);
}

public 
Action:OnFinishRound(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    
SavePlayerInfo(client);
}
public 
SavePlayerInfo(client)
{
    new 
Handle:DB CreateKeyValues("PlayersInfo");
    
FileToKeyValues(DBKVPath);
    
    new 
String:SteamID[32];
    
    
GetClientAuthString(clientSteamIDsizeof(SteamID));
    if(
KvJumpToKey(DBSteamIDtrue))
    {
        new 
String:name[MAX_NAME_LENGTH], String:temp_name[MAX_NAME_LENGTH];
            
        
GetClientName(clientnamesizeof(name));
            
        
KvGetString(DB"name"temp_namesizeof(temp_name), "NULL");
            
        if(
GetConVarInt(h_pointsmap) == 1)
        {
            
GetConVarInt(h_pointsdifficulteasy);
            
h_pointsdifficulteasy KvGetNum(DB"points");
            
//KvGetNum( Errrrrror.
        
}
        if(
GetConVarInt(h_pointsmap) == 2)
        {
            
GetConVarInt(h_pointsdifficultnormal);
            
h_pointsdifficultnormal KvGetNum(DB"points");
        }
        if(
GetConVarInt(h_pointsmap) == 3)
        {
            
GetConVarInt(h_pointsdifficulthard);
            
h_pointsdifficulthard KvGetNum(DB"points");
        }
        new 
Finishedmaps KvGetNum(DB"Finishedmaps");
        if(
StrEqual(temp_name"NULL") && points == && Finishedmaps == 0)
        {
            
PrintToChatAll("[Lagoon] %s est un nouveau joueur"name);
        }
    else
    {
        
PrintToChatAll("[Lagoon] %s dernière connexion sous le pseudo %s./n Et il a %d points, il a fini %d maps."nametemp_namepointsFinishedmaps);
    }
            
        
points++;
        
Finishedmaps++;
            
        
KvGetNum(DB"points"points);
        
KvGetNum(DB"Finishedmaps"Finishedmaps);
        
KvRewind(DB);
        
CloseHandle();
    }

I fixed one error, and marked another. I also fixed the terrible coding (I.e: indenting several times when it's not needed.) I couldn't test it, since I don't have the needed libraries, but I'm sure someone else can fix the rest.

Last edited by Hunter S. Thompson; 12-02-2012 at 16:08.
Hunter S. Thompson is offline
blacklagoon
Senior Member
Join Date: Jun 2012
Old 12-03-2012 , 00:19   Re: [CS:S] Rank Module attempt for CS:S Timer 1.0.6
Reply With Quote #3

Thanks, i understand the error you marked :p !
And i thinked i understand what you fixed, so i needed to hook an event?
blacklagoon is offline
Glite
Senior Member
Join Date: Sep 2011
Location: Ukraine
Old 12-03-2012 , 00:39   Re: [CS:S] Rank Module attempt for CS:S Timer 1.0.6
Reply With Quote #4

PHP Code:
public Action:OnFinishRound(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    
SavePlayerInfo(client);

Lol, really?

PHP Code:
forward OnFinishRound(client, const String:map[], jumpsflashbangsphysicsDifficultyfpsmax, const String:timeString[], const String:timeDiffString[], positiontotalrankbool:overwrite); 

Last edited by Glite; 12-03-2012 at 00:40.
Glite is offline
blacklagoon
Senior Member
Join Date: Jun 2012
Old 12-03-2012 , 01:43   Re: [CS:S] Rank Module attempt for CS:S Timer 1.0.6
Reply With Quote #5

hmm i don't understand at all x)
but i think i've seen an error with the cvar, i should put a min and max value :p !
should i ?
PHP Code:
h_pointdifficulteasy CreateConVar("sm_pointeasy""10""Set point win for easy difficulty def is 10 point"FCVAR_NOTIFY); 
Hmmm, what should it be then Glite? :p

Last edited by blacklagoon; 12-03-2012 at 02:11.
blacklagoon is offline
blacklagoon
Senior Member
Join Date: Jun 2012
Old 12-06-2012 , 04:21   Re: [CS:S] Rank Module attempt for CS:S Timer 1.0.6
Reply With Quote #6

Any one plz ?
blacklagoon 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 12:06.


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