Hunter S. Thompson |
12-02-2012 16:01 |
Re: [CS:S] Rank Module attempt for CS:S Timer 1.0.6
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_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"); 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(DB, KVPath); new String:SteamID[32]; GetClientAuthString(client, SteamID, sizeof(SteamID)); if(KvJumpToKey(DB, SteamID, true)) { new String:name[MAX_NAME_LENGTH], String:temp_name[MAX_NAME_LENGTH]; 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( 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 == 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(); } }
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.
|