Modificare plugin points

Modificari necesare ale pluginurilor

Moderators: Moderatori ajutatori, Moderatori

Post Reply
User avatar
Xeno985
Membru, skill 0
Membru, skill 0
Posts: 88
Joined: 05 Jul 2017, 21:07
Detinator Steam: Da
CS Status: Disponibil, doar cand sunt acasa.
Detinator server CS: Nu.
SteamID: 512916512916
Fond eXtream: 0
Location: Ploiesti
Contact:

02 Aug 2018, 22:15

Salut, navigand pe internet, am dat peste un plugin pentru exp, ulterior i-am facut cateva modificari, iar acum este de points, totusi as dori ca atunci cand un player planteaza bomba sa primeasca x points (cvar), iar daca explodeaza inca y points (cvar), iar daca CT dezamorseaza bomba sa primeasca z points (cvar).
| Afiseaza codul
#include <amxmodx> 
#include <sqlx> 

#define PLUGIN "Tutorial" 
#define VERSION "1.0" 
#define AUTHOR "Grim" 

new Host[]      = "localhost"
new User[]      = "root"
new Pass[]      = ""
new Db[]        = "db_test"

new Handle:g_SqlTuple
new g_Error[512]
new Points[33]
new cKill
new cHeadshot
new server_id

public plugin_init()  
{ 
    register_plugin(PLUGIN, VERSION, AUTHOR) 
    register_event("DeathMsg", "Event_DeathMsg", "a")  
    cKill = register_cvar("kill_point", "1") 
    cHeadshot = register_cvar("headshot_point", "2") 
    server_id = register_cvar("for_server_id", "1") 
    set_task(1.0, "MySql_Init")  
} 

public MySql_Init() 
{ 
    g_SqlTuple = SQL_MakeDbTuple(Host,User,Pass,Db) 
    new ErrorCode,Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,charsmax(g_Error)) 
    if(SqlConnection == Empty_Handle) 
        set_fail_state(g_Error) 
    new Handle:Queries 
    Queries = SQL_PrepareQuery(SqlConnection,"CREATE TABLE IF NOT EXISTS `players` (`id` int(11) NOT NULL, `steamid` varchar(55) NOT NULL, `password` varchar(32) NOT NULL, `points` int(11) NOT NULL, `for_server_id` int(11) NOT NULL, `type` varchar(32) NOT NULL DEFAULT 'none')") 

    if(!SQL_Execute(Queries)) 
    { 
        SQL_QueryError(Queries,g_Error,charsmax(g_Error)) 
        set_fail_state(g_Error) 
        
    } 
    SQL_FreeHandle(Queries) 
    SQL_FreeHandle(SqlConnection)    
} 

public plugin_end() 
{ 
    SQL_FreeHandle(g_SqlTuple) 
} 

public Load_MySql(id) 
{ 
    new szSteamId[32], szTemp[512] 
    get_user_authid(id, szSteamId, charsmax(szSteamId)) 
     
    new Data[1] 
    Data[0] = id 
    format(szTemp,charsmax(szTemp),"SELECT * FROM `players` WHERE (`players`.`steamid` = '%s' AND `players`.`for_server_id` = '%i')", szSteamId, get_pcvar_num(server_id)) 
    SQL_ThreadQuery(g_SqlTuple,"register_client",szTemp,Data,1) 
} 

public register_client(FailState,Handle:Query,Error[],Errcode,Data[],DataSize) 
{ 
    if(FailState == TQUERY_CONNECT_FAILED) 
    { 
        log_amx("Load - Could not connect to SQL database.  [%d] %s", Errcode, Error) 
    } 
    else if(FailState == TQUERY_QUERY_FAILED) 
    { 
        log_amx("Load Query failed. [%d] %s", Errcode, Error) 
    } 

    new id 
    id = Data[0] 
     
    if(SQL_NumResults(Query) < 1)  
    { 
         
        new szSteamId[32] 
        get_user_authid(id, szSteamId, charsmax(szSteamId))  

        if (equal(szSteamId,"ID_PENDING")) 
            return PLUGIN_HANDLED 
             
        new szTemp[512] 

        format(szTemp,charsmax(szTemp),"INSERT INTO `players` (`steamid`, `points`, `for_server_id`) VALUES ('%s', '0', '%i');",szSteamId, get_pcvar_num(server_id)) 
        SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp) 
    }  
    else  
    { 
        Points[id]         = SQL_ReadResult(Query, 1) 
    } 
     
    return PLUGIN_HANDLED 
} 

public Save_MySql(id) 
{ 
    new szSteamId[32], szTemp[512] 
    get_user_authid(id, szSteamId, charsmax(szSteamId)) 

    format(szTemp,charsmax(szTemp),"UPDATE `players` SET `points` = `points` + '%i' WHERE `players`.`steamid` = '%s' AND `players`.`for_server_id` = '%i'",Points[id], szSteamId, get_pcvar_num(server_id)) 
    SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp) 
} 

public IgnoreHandle(FailState,Handle:Query,Error[],Errcode,Data[],DataSize) 
{ 
    SQL_FreeHandle(Query) 
     
    return PLUGIN_HANDLED 
} 

public client_putinserver(id) 
{ 
    Load_MySql(id) 
} 

public client_disconnect(id) 
{ 
    Save_MySql(id) 
} 

public Event_DeathMsg() 
{ 
    new iKiller = read_data(1) // read the data to get the killer and victim 
     
    if(is_user_alive(iKiller)) // Check if the killer is alive in case he killed himself 
    { 
        if(read_data(3)) 
        { 
            Points[iKiller] += get_pcvar_num(cHeadshot) // Add the amount of the Pcvar to Points 
        } 
        else 
        { 
            Points[iKiller] += get_pcvar_num(cKill) 
        } 
    }
}
Mai am de adaugat urmatoarele intrebari despre modificarile pe care l-am adus pluginului:
1. Este corect formatul de la sfarsit prin care am chemat variabila din cvar?

Code: Select all

format(szTemp,charsmax(szTemp),"UPDATE `players` SET `points` = '%i' WHERE `players`.`steamid` = '%s' AND `players`.`for_server_id` = '%s'",Points[id], szSteamId, get_pcvar_num(server_id)) 
2. "szSteamId" este numele sau steamid-ul jucatorului (STEAM:0:X:XXXXXXXXX)?

Cam astea sunt problemele cu care ma confrunt acum. Am incercat sa compilez pluginul si a mers cu succes. Astept raspunsul unei persoane care cunoaste mai bine pentru a ma ajuta cu bomba aia ...
Last edited by Xeno985 on 10 Aug 2018, 22:52, edited 1 time in total.
Click | Afiseaza codul
Bau
Index gaming: Click.
Panel Counter-Strike: Click.
Olium
User avatar
YONTU
Moderator ajutator
Moderator ajutator
Posts: 2911
Joined: 10 May 2013, 13:25
Detinator Steam: Nu
CS Status: Everyone is looking at ur shoes
Reputatie: Moderator ajutator
Fost scripter eXtreamCS
Location: Gura Humorului
Has thanked: 260 times
Been thanked: 279 times
Contact:

10 Aug 2018, 11:55

1. Cvarul e de tip int, deci cand faci apel o transmiți sub formatul %i, și nu %s. S vine de la string
2. Este steamid ul
„Peste douăzeci de ani vei fi dezamăgit din cauza lucrurilor pe care nu le-ai făcut, nu din cauza celor pe care le-ai făcut.” - Mark Twain
„Asa e si in viata, hotii castiga, prostii care invata pierd.” - Mihai Nemeș
Pluginurile mele publice | Afiseaza codul
Control HE Damage(s)
[Zombie mod] Liderul oamenilor
NO RUSH (MANUAL)
Salvatorul Craciunului
Harry Potter's Magic Wand [0.0.3]
New HE Grenade Effects
Upgrades Menu -> Health/Armor/Damage
Serverele care au achizitonat pluginurile mele: #1 #2

CONTACT: sef_yontu@yahoo.com | skype: cyp_yontu
User avatar
Xeno985
Membru, skill 0
Membru, skill 0
Posts: 88
Joined: 05 Jul 2017, 21:07
Detinator Steam: Da
CS Status: Disponibil, doar cand sunt acasa.
Detinator server CS: Nu.
SteamID: 512916512916
Fond eXtream: 0
Location: Ploiesti
Contact:

10 Aug 2018, 14:51

YONTU wrote:1. Cvarul e de tip int, deci cand faci apel o transmiți sub formatul %i, și nu %s. S vine de la string
2. Este steamid ul
Mulțumesc pentru ajutor, rămâne cea de a treia problema, implementarea unui sistem ce oferă puncte pentru plant, defuse and explode bomb (C4).
Click | Afiseaza codul
Bau
Index gaming: Click.
Panel Counter-Strike: Click.
User avatar
Xeno985
Membru, skill 0
Membru, skill 0
Posts: 88
Joined: 05 Jul 2017, 21:07
Detinator Steam: Da
CS Status: Disponibil, doar cand sunt acasa.
Detinator server CS: Nu.
SteamID: 512916512916
Fond eXtream: 0
Location: Ploiesti
Contact:

11 Aug 2018, 01:40

Rezolvat:
| Afiseaza codul
#include <amxmodx> 
#include <amxmisc>
#include <cstrike>
#include <csx>
#include <sqlx> 

#define PLUGIN "Points SQL" 
#define VERSION "1.0" 
#define AUTHOR "LuciaNNN." 

new Host[]      = "localhost"
new User[]      = "root"
new Pass[]      = ""
new Db[]        = "db_test"

new Handle:g_SqlTuple
new g_Error[512]
new Points[33]
new cKill
new cHeadshot
new server_id

new pBonus
new dBonus
new eBonus

new website

public plugin_init()  
{ 
    register_plugin(PLUGIN, VERSION, AUTHOR) 
	register_event("TextMsg", "bomb_planted", "a", "2&%!MRAD_BOMBPL") 
	register_event("TextMsg", "bomb_defused", "a", "2&%!MRAD_BOMBDEF") 
	register_event("TextMsg", "bomb_explode", "a", "2&#Target_B") 

    cKill = register_cvar("kill_point", "1") 
    cHeadshot = register_cvar("headshot_point", "2") 
    server_id = register_cvar("for_server_id", "1") 
	pBonus = register_cvar("bomb_planted_bonus","3") 
	dBonus = register_cvar("bomb_defused_bonus","6") 
	eBonus = register_cvar("bomb_explode_bonus","3") 
	website = register_cvar("web_site","http://www.panel.ro") 

    set_task(1.0, "MySql_Init") 
    set_task(60.0,"show_msg",0,"",0,"b",0)
} 

public MySql_Init() 
{ 
    g_SqlTuple = SQL_MakeDbTuple(Host,User,Pass,Db) 
    new ErrorCode,Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,charsmax(g_Error)) 
    if(SqlConnection == Empty_Handle) 
        set_fail_state(g_Error) 
    new Handle:Queries 
    Queries = SQL_PrepareQuery(SqlConnection,"CREATE TABLE IF NOT EXISTS `players` (`id` int(11) NOT NULL AUTO_INCREMENT, `steamid` varchar(55) NOT NULL, `password` varchar(32) NOT NULL, `points` int(11) NOT NULL, `for_server_id` int(11) NOT NULL, `type` varchar(32) NOT NULL DEFAULT 'none', PRIMARY KEY (`id`))") 

    if(!SQL_Execute(Queries)) 
    { 
        SQL_QueryError(Queries,g_Error,charsmax(g_Error)) 
        set_fail_state(g_Error) 
        
    } 
    SQL_FreeHandle(Queries) 
    SQL_FreeHandle(SqlConnection)    
} 

public show_msg() {
	new cvar[64] 
	get_pcvar_string(website, cvar, 64) 
	ColorChat(0,"!n[!gPOINTS!n]  Pentru a folosi punctele intra pe panel la adresa !t%s!n sectiunea !tSHOP!n.", cvar) 
}

public plugin_end() 
{ 
    SQL_FreeHandle(g_SqlTuple) 
} 

public Load_MySql(id) 
{ 
    new szSteamId[32], szTemp[512] 
    get_user_authid(id, szSteamId, charsmax(szSteamId)) 
     
    new Data[1] 
    Data[0] = id 
    format(szTemp,charsmax(szTemp),"SELECT * FROM `players` WHERE (`players`.`steamid` = '%s' AND `players`.`for_server_id` = '%i')", szSteamId, get_pcvar_num(server_id)) 
    SQL_ThreadQuery(g_SqlTuple,"register_client",szTemp,Data,1) 
} 

public register_client(FailState,Handle:Query,Error[],Errcode,Data[],DataSize) 
{ 
    if(FailState == TQUERY_CONNECT_FAILED) 
    { 
        log_amx("Load - Could not connect to SQL database.  [%d] %s", Errcode, Error) 
    } 
    else if(FailState == TQUERY_QUERY_FAILED) 
    { 
        log_amx("Load Query failed. [%d] %s", Errcode, Error) 
    } 

    new id 
    id = Data[0] 
     
    if(SQL_NumResults(Query) < 1)  
    { 
         
        new szSteamId[32] 
        get_user_authid(id, szSteamId, charsmax(szSteamId))  

        if (equal(szSteamId,"ID_PENDING")) 
            return PLUGIN_HANDLED 
             
        new szTemp[512] 

        format(szTemp,charsmax(szTemp),"INSERT INTO `players` (`steamid`, `points`, `for_server_id`) VALUES ('%s', '0', '%i');",szSteamId, get_pcvar_num(server_id)) 
        SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp) 
    }  
    else  
    { 
        Points[id]         = SQL_ReadResult(Query, 1) 
    } 
     
    return PLUGIN_HANDLED 
} 

public Save_MySql(id) 
{ 
    new szSteamId[32], szTemp[512] 
    get_user_authid(id, szSteamId, charsmax(szSteamId)) 

    format(szTemp,charsmax(szTemp),"UPDATE `players` SET `points` = `points` + '%i' WHERE `players`.`steamid` = '%s' AND `players`.`for_server_id` = '%i'",Points[id], szSteamId, get_pcvar_num(server_id)) 
    SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp) 
} 

public IgnoreHandle(FailState,Handle:Query,Error[],Errcode,Data[],DataSize) 
{ 
    SQL_FreeHandle(Query) 
     
    return PLUGIN_HANDLED 
} 

public client_putinserver(id) 
{ 
    Load_MySql(id) 
} 

public client_disconnect(id) 
{ 
    Save_MySql(id) 
} 

public bomb_planted(id)
{
    new bonus = get_pcvar_num(pBonus)
    new szSteamId[32], szTemp[512] 
    get_user_authid(id, szSteamId, charsmax(szSteamId)) 

    format(szTemp,charsmax(szTemp),"UPDATE `players` SET `points` = `points` + '%i' WHERE `players`.`steamid` = '%s' AND `players`.`for_server_id` = '%i'",bonus, szSteamId, get_pcvar_num(server_id)) 
    SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp) 

    ColorChat(id, "!n[!gPOINTS!n]  Ai primit !t%i !npoints pentru ca ai plantat bomba.", bonus)
    return PLUGIN_HANDLED
}

public bomb_defused(id)
{
    new bonus = get_pcvar_num(dBonus)
    new szSteamId[32], szTemp[512] 
    get_user_authid(id, szSteamId, charsmax(szSteamId)) 

    format(szTemp,charsmax(szTemp),"UPDATE `players` SET `points` = `points` + '%i' WHERE `players`.`steamid` = '%s' AND `players`.`for_server_id` = '%i'",bonus, szSteamId, get_pcvar_num(server_id)) 
    SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp) 

	ColorChat(id, "!n[!gPOINTS!n] Ai primit !t%i !npentru ca ai dezamorsat bomba.", bonus)
    return PLUGIN_HANDLED
}

public bomb_explode(id)
{
    new bonus = get_pcvar_num(eBonus)
    new szSteamId[32], szTemp[512] 
    get_user_authid(id, szSteamId, charsmax(szSteamId)) 

    format(szTemp,charsmax(szTemp),"UPDATE `players` SET `points` = `points` + '%i' WHERE `players`.`steamid` = '%s' AND `players`.`for_server_id` = '%i'",bonus, szSteamId, get_pcvar_num(server_id)) 
    SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp) 

	ColorChat(id, "!n[!gPOINTS!n] Ai primit !t%i !npentru ca ai avut grija ca bomba sa explodeze.", bonus)
    return PLUGIN_HANDLED
}

public Event_DeathMsg() 
{ 
    new iKiller = read_data(1) // read the data to get the killer and victim 
     
    if(is_user_alive(iKiller)) // Check if the killer is alive in case he killed himself 
    { 
        if(read_data(3)) 
        { 
            Points[iKiller] += get_pcvar_num(cHeadshot) // Add the amount of the Pcvar to Points 
        } 
        else 
        { 
            Points[iKiller] += get_pcvar_num(cKill) 
        } 
    }
}

stock ColorChat(const id, const input[], any:...)
{
	new count = 1, players[32]
	static msg[320]
	vformat(msg, 190, input, 3)
	replace_all(msg, 190, "!g", "^4")
	replace_all(msg, 190, "!n", "^1")
	replace_all(msg, 190, "!t", "^3")
	replace_all(msg, 190, "!t2", "^0")
	if (id) players[0] = id; else get_players(players, count, "ch")
{
	for (new i = 0; i < count; i++)
	{
		if (is_user_connected(players))
		{
			message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players)
			write_byte(players)
			write_string(msg)
			message_end()
		}
	}
}
}
Click | Afiseaza codul
Bau
Index gaming: Click.
Panel Counter-Strike: Click.
Post Reply

Return to “Modificari pluginuri”

  • Information
  • Who is online

    Users browsing this forum: Baidu [Spider] and 12 guests