Raised This Month: $32 Target: $400
 8% 

[Help] SRank


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DeadSwim
Junior Member
Join Date: Mar 2019
Location: On PC
Old 03-08-2019 , 03:26   [Help] SRank
Reply With Quote #1

Hello, I have such a problem, I use the SRank plugin and there is such a problem that when a new player joins the server, it will give him basically random points, kills, deaths, headshot, etc ... would you help me to make it random kills deaths etc ... but to create a mysql new account completely empty?


I apologize for my English: D

SRank.sp

PHP Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <cstrike>
#include "ShadowLibs/srank_mysql.sp"
new Handle:g_PointsPerKill;
new 
Handle:g_PointsPlant;
new 
Handle:g_PointsBonus;
int kd;


public 
OnPluginStart()
{
    
RunDataBaseSetUp();
    
RegConsoleCmd("sm_stats",Cmd_Stats);
    
RegConsoleCmd("sm_top",Cmd_Top);
    
HookEvent("player_death"OnPlayerDeath);
    
HookEvent("bomb_planted"OnBombPlant);
    
HookEvent("player_spawn"OnPlayerSpawn);
    
g_PointsPerKill CreateConVar("srank_PointsPerKill","3","Amount of points given to a player per kill.");
    
g_PointsPlant CreateConVar("srank_PointsForBombPlant","5","Amount of points given to a when they plant the bomb.");
    
g_PointsBonus CreateConVar("srank_PointsBonus","3","Amount of points to be given on top of 'PointsPerKill' when player has done a special event etc 'Headshots'.");
    
AutoExecConfig(true,"Srank");
}

public 
Action:Cmd_Stats(client,args)
{
    if(
IsClientInGame(client))
    {
        
SrankStatsMenu(client);
    }
    return 
Plugin_Handled;
}

public 
Action:Cmd_Top(client,args)
{
    if(
IsClientInGame(client))
    {
        
//SrankTopMenu(client);
        
PrintToChat(client," \x02\x0C[AIM] \x02 Tento příkaz není dostupný.")
    }
    return 
Plugin_Handled;
}

SrankStatsMenu(client)
{
    new 
Handle:panel CreatePanel(INVALID_HANDLE);
    new 
String:KillsFormat[512];
    new 
String:DeathsFormat[512];
    new 
String:PointsFormat[512];
    new 
String:HeadshotsFormat[150];
    new 
String:NameFormat[150];
    new 
String:BombPlantFormat[150];
    
kd PlayerKills[client] / PlayerDeaths[client];
    new 
String:kdFormat[512];
    
Format(KillsFormat,sizeof(KillsFormat),"[%i]"PlayerKills[client]);
    
Format(HeadshotsFormat,sizeof(HeadshotsFormat),"[%i]"PlayerHeadShots[client]);
    
Format(DeathsFormat,sizeof(DeathsFormat),"[%i]"PlayerDeaths[client]);
    
Format(PointsFormat,sizeof(PointsFormat),"[%i]"PlayerPoints[client]);
    
Format(kdFormat,sizeof(kdFormat),"[%i]"kd);
    
Format(NameFormat,sizeof(NameFormat),"%s - [Stats]"PlayerName[client]);
            
PrintToChat(client" \x04 ________________________________________________________");
            
PrintToChat(client" Vaše zabití: %i Vaše umrtí: %i Vaše HeadShots: %i",PlayerKills[client],PlayerDeaths[client],PlayerHeadShots[client]);
            
PrintToChat(client" Vaše pointy: %i Vaše K/D: %i"PlayerPoints[client], kd);
            if(
PlayerPoints[client] >= 10000)
            {
            
PrintToChat(client" Váš rank: LEGENDA!");
            }
            else if(
PlayerPoints[client] >= 5000)
            {
            
PrintToChat(client" Váš rank: The Global Elite");
            }
            if(
PlayerPoints[client] >= 4000)
            {
            
PrintToChat(client" Váš rank: Supreme Master First Class");
            }
            else if(
PlayerPoints[client] >= 3500)
            {
            
PrintToChat(client" Váš rank: Legendary Eagle Master");
            }
            else if(
PlayerPoints[client] >= 2800)
            {
            
PrintToChat(client" Váš rank: Distinguished Master Guardian");
            }
            else if(
PlayerPoints[client] >= 2450)
            {
            
PrintToChat(client" Váš rank: Master Guardian Elite");
            }
            else if(
PlayerPoints[client] >= 2250)
            {
            
PrintToChat(client" Váš rank: Master Guardian II");
            }
            else if(
PlayerPoints[client] >= 2000)
            {
            
PrintToChat(client" Váš rank: Master Guardian I");
            }
            else if(
PlayerPoints[client] >= 1500)
            {
            
PrintToChat(client" Váš rank: Gold Nova Master");
            }
            else if(
PlayerPoints[client] >= 1100)
            {
            
PrintToChat(client" Váš rank: Gold Nova III");
            }
            else if(
PlayerPoints[client] >= 950)
            {
            
PrintToChat(client" Váš rank: Gold Nova II");
            }
            else if(
PlayerPoints[client] >= 800)
            {
            
PrintToChat(client" Váš rank: Gold Nova I");
            }
            else if(
PlayerPoints[client] >= 650)
            {
            
PrintToChat(client" Váš rank: Silver Elite Master");
            }
            else if(
PlayerPoints[client] >= 500)
            {
            
PrintToChat(client" Váš rank: Silver Elite");
            }
            else if(
PlayerPoints[client] >= 300)
            {
            
PrintToChat(client" Váš rank: Silver IV");
            }
            else if(
PlayerPoints[client] >= 250)
            {
            
PrintToChat(client" Váš rank: Silver III");
            }
            else if(
PlayerPoints[client] >= 200)
            {
            
PrintToChat(client" Váš rank: Silver II");
            }
            else if(
PlayerPoints[client] >= 0)
            {
            
PrintToChat(client" Váš rank: Silver I");
            }
            
PrintToChat(client" \x04 ________________________________________________________");
}
public 
OnPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{

    new 
client_id GetEventInt(event"userid");
    new 
client GetClientOfUserId(client_id);
    new 
String:KillsFormat[512];
    new 
String:DeathsFormat[512];
    new 
String:PointsFormat[512];
    new 
String:HeadshotsFormat[150];
    new 
String:NameFormat[150];
    new 
String:BombPlantFormat[150];
    
kd PlayerKills[client] / PlayerDeaths[client];
    new 
String:kdFormat[512];
    
Format(KillsFormat,sizeof(KillsFormat),"[%i]"PlayerKills[client]);
    
Format(HeadshotsFormat,sizeof(HeadshotsFormat),"[%i]"PlayerHeadShots[client]);
    
Format(DeathsFormat,sizeof(DeathsFormat),"[%i]"PlayerDeaths[client]);
    
Format(PointsFormat,sizeof(PointsFormat),"[%i]"PlayerPoints[client]);
    
Format(kdFormat,sizeof(kdFormat),"[%i]"kd);
    
Format(NameFormat,sizeof(NameFormat),"%s - [Stats]"PlayerName[client]);
            if(
PlayerPoints[client] >= 10000)
            {
            
CS_SetClientClanTag(client"LEGENDA!"); 
            }
            else if(
PlayerPoints[client] >= 5000)
            {
            
CS_SetClientClanTag(client"The Global Elite"); 
            }
            if(
PlayerPoints[client] >= 4000)
            {
            
CS_SetClientClanTag(client"Supreme"); 
            }
            else if(
PlayerPoints[client] >= 3500)
            {
            
CS_SetClientClanTag(client"Legendary Eagle Master"); 
            }
            else if(
PlayerPoints[client] >= 2800)
            {
            
CS_SetClientClanTag(client"DMG"); 
            }
            else if(
PlayerPoints[client] >= 2450)
            {
            
CS_SetClientClanTag(client"Master Guardian E."); 
            }
            else if(
PlayerPoints[client] >= 2250)
            {
            
CS_SetClientClanTag(client"Master Guardian II"); 
            }
            else if(
PlayerPoints[client] >= 2000)
            {
            
CS_SetClientClanTag(client"Master Guardian I"); 
            }
            else if(
PlayerPoints[client] >= 1500)
            {
            
CS_SetClientClanTag(client"Gold N. M."); 
            }
            else if(
PlayerPoints[client] >= 1100)
            {
            
CS_SetClientClanTag(client"Gold III"); 
            }
            else if(
PlayerPoints[client] >= 950)
            {
            
CS_SetClientClanTag(client"Gold II"); 
            }
            else if(
PlayerPoints[client] >= 800)
            {
            
CS_SetClientClanTag(client"Gold I"); 
            }
            else if(
PlayerPoints[client] >= 650)
            {
            
CS_SetClientClanTag(client"Silver E. M."); 
            }
            else if(
PlayerPoints[client] >= 500)
            {
            
CS_SetClientClanTag(client"Silver Elite"); 
            }
            else if(
PlayerPoints[client] >= 300)
            {
            
CS_SetClientClanTag(client"Silver IV"); 
            }
            else if(
PlayerPoints[client] >= 250)
            {
            
CS_SetClientClanTag(client"Silver III"); 
            }
            else if(
PlayerPoints[client] >= 200)
            {
            
CS_SetClientClanTag(client"Silver II"); 
            }
            else if(
PlayerPoints[client] >= 0)
            {
            
CS_SetClientClanTag(client"Silver I"); 
            }
}

public 
StatsHandle(Handle:menuMenuAction:actionparam1param2)
{
    switch(
action)
    {
        case 
MenuAction_Select:
        {
            
decl String:info[32];
            
GetMenuItem(menuparam2infosizeof(info));
            
            if (
StrEqual(info"Close"))
            {
                
PrintToChat(param1,"\x02\x0C[AIM] \x02 Panel statistik byl uzavřen.")
            }    
            
        }
    }
}

public 
OnClientPutInServer(client)
{
    
SrankLoad(client);
}
public 
OnClientDisconnect(client)
{
    
SrankSave(client);    
}

public 
SrankSave(client)
{
    if (!
IsClientInGame(client))
        return;
    
    new 
String:query[400], String:auth[400];
    
GetClientAuthString(clientauthsizeof(auth));
    
GetClientName(clientPlayerName[client],sizeof(PlayerName));
    
Format(querysizeof(query), "UPDATE srank2 SET name = %d,kills = %d,deaths = %d,headshots = %d, points = %d WHERE steamid = '%s'",PlayerName[client],PlayerKills[client],PlayerDeaths[client],PlayerHeadShots[client],PlayerPoints[client],auth);
    
SQL_TQuery(hDatabaseSrank_Savequeryclient);


public 
SrankLoad(client)
{
    new 
String:query[400], String:auth[400];
    
GetClientAuthString(clientauthsizeof(auth));
    
Format(querysizeof(query), "SELECT * FROM srank2 WHERE steamid = '%s'"auth);
    
    
SQL_TQuery(hDatabaseSrank_Loadqueryclient);
}

public 
OnPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
victimId GetEventInt(event"userid")
    new 
attackerId GetEventInt(event"attacker")
    new 
bool:headshot GetEventBool(event"headshot")
    new 
victim GetClientOfUserId(victimId)
    new 
attacker GetClientOfUserId(attackerId)
    new 
String:VictimName[100]
    new 
String:AttackerName[100]
    
GetClientName(victimVictimName,sizeof(VictimName));
    
GetClientName(attackerAttackerName,sizeof(AttackerName));
    
PlayerDeaths[victim]++;
    
PrintToChat(victim,"\x02\x0C[AIM] \x07 %s \x02 byl jsi zabit \x07 %s",VictimName,AttackerName);
    
PrintToChat(victim,"\x02\x0C[AIM] \x07 %s \x02 ztratil jsi \x07 3 Points za smrt",VictimName);
    
PlayerPoints[victim] -= GetConVarInt(g_PointsBonus);
    if(
headshot)
    {
        
PlayerHeadShots[attacker]++;
        
PlayerPoints[attacker] += GetConVarInt(g_PointsPerKill) + GetConVarInt(g_PointsBonus);
        
PrintToChat(attacker,"\x02\x0C[AIM] \x02 Získal jsi \x07 %i \x02 pointu za headshot!",GetConVarInt(g_PointsPerKill) + GetConVarInt(g_PointsBonus));
    }
    else
    {
        
PlayerKills[attacker]++;
        
PlayerPoints[attacker] += GetConVarInt(g_PointsPerKill);
        
PrintToChat(attacker,"\x02\x0C[AIM] \x02 Získal jsi \x07%i \x02 pointu za kill!",GetConVarInt(g_PointsPerKill));
    }
    
SrankSave(attacker);
    
SrankSave(victim);
}
    
public 
OnBombPlant(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
clientID GetEventInt(event"userid")
    new 
client GetClientOfUserId(clientID)
    if(
GetClientTeam(client) == CS_TEAM_T)
    {
        
PlayerPoints[client] += GetConVarInt(g_PointsPlant);
        
PlayerBombPlant[client] += 1;
        
PrintToChat(client,"\x02\x0C[AIM] \x02 Získal jsi \x07%i \x02 za plant bomby!",GetConVarInt(g_PointsPlant));
        
SrankSave(client);
    }

srank_mysql.sp

PHP Code:
///////////////////////////////////////////////
new Handle:hDatabase INVALID_HANDLE;
static 
String:DBERROR[600];
////////////////////////////////////////////////
new String:PlayerName[MAXPLAYERS+1];
new 
PlayerKills[MAXPLAYERS+1];
new 
PlayerDeaths[MAXPLAYERS+1];
new 
PlayerHeadShots[MAXPLAYERS+1];
new 
PlayerPoints[MAXPLAYERS+1];
new 
PlayerBombPlant[MAXPLAYERS+1];
public 
RunDataBaseSetUp()
{
    
hDatabase SQL_Connect("SRank"trueDBERRORsizeof(DBERROR));
    if(
hDatabase == INVALID_HANDLE)
    {
        
SQL_GetError(hDatabaseDBERRORsizeof(DBERROR));
        
SetFailState("\n\n[ERROR:1-a] Connection to the database has failed-: %s\n\n"DBERROR);
    }
    
SQL_Query(hDatabase"CREATE TABLE IF NOT EXISTS srank2(steamid VARCHAR(255) NOT NULL PRIMARY KEY, name VARCHAR(255) NOT NULL, kills INT(255) NOT NULL, deaths INT(255) NOT NULL, headshots INT(255) NOT NULL, points INT(255) NOT NULL, bombplant INT(255) NOT NULL);");
    
    
//CloseHandle(db);
}

public 
Srank_Load(Handle:ownerHandle:hndl, const String:error[], any:client)
{
    if (!
IsClientInGame(client))
        return;
    
    if (
hndl == INVALID_HANDLE)
    {
        
PrintToServer("SQL Load failed.");
        return;
    }
    
    if (
SQL_GetRowCount(hndl) == 0)
    {
        new 
String:query[300], String:auth[400];
        
GetClientAuthString(clientauthsizeof(auth));
        
Format(querysizeof(query), "INSERT IGNORE INTO srank2 (steamid) VALUES ('%s')"auth);
        
SQL_TQuery(hDatabaseSrank_CreateAccountqueryclient);
    }
    else
    {
        
SQL_FetchRow(hndl);
        
PlayerName[client] = SQL_FetchString(hndl1PlayerName[client], sizeof(PlayerName));
        
PlayerKills[client] = SQL_FetchInt(hndl2);
        
PlayerDeaths[client] = SQL_FetchInt(hndl3);
        
PlayerHeadShots[client] = SQL_FetchInt(hndl4);
        
PlayerPoints[client] = SQL_FetchInt(hndl5);
        
PlayerBombPlant[client] = SQL_FetchInt(hndl6);
    }
    
PrintToChat(client"\x02\x0C[Deathmatch] \x06Váš profil byl načten.");
}
public 
Srank_CreateAccount(Handle:ownerHandle:hndl, const String:error[], any:client)
{
    if (!
IsClientConnected(client))
    {
        return;
    }
    if (!
IsClientInGame(client))
    {
        return;
    }
    
PrintToChat(client"\x02\x0C[Deathmatch] \x06Váš profil byl načten.");
}
public 
Srank_Save(Handle:ownerHandle:hndl, const String:error[], any:client)
{

DeadSwim 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 23:35.


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