Raised This Month: $51 Target: $400
 12% 

Solved [REQUEST] Can someone fix this code that was generated with chatgpt?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GhnRyoku
New Member
Join Date: Apr 2023
Old 04-18-2023 , 07:18   [REQUEST] Can someone fix this code that was generated with chatgpt?
Reply With Quote #1

Hello i dont know how to code but i wanted to see if chatgpt could create me a csgo plugin that i want in my server

I wanted to make a plugin would reward online players 10 points every minute


Can someone fix this?

#include <sourcemod>

public void OnPluginStart()
{
// Register the command to reward players
RegConsoleCmd("reward", Cmd_Reward);

// Create a timer to reward players every minute
CreateTimer(60.0, Timer_Reward, _, TIMER_REPEAT);
}

public Action Cmd_Reward(int client, const char[] args)
{
// Get the client's SteamID
new steamid[20];
GetClientAuthId(client, steamid, sizeof(steamid));

// Reward the client with 100 points
RewardPlayer(steamid, 100);

return Plugin_Handled;
}

public Action Timer_Reward(Handle timer)
{
// Loop through all connected clients
for (int i = 1; i <= MaxClients; i++)
{
// Check if the client is connected
if (IsClientInGame(i))
{
// Get the client's SteamID
new steamid[20];
GetClientAuthId(i, steamid, sizeof(steamid));

// Reward the client with 10 points
RewardPlayer(steamid, 10);
}
}

return Plugin_Continue;
}

public void RewardPlayer(const char[] steamid, int points)
{
// Open a connection to the MySQL database
new database = SQL_Connect("localhost", "username", "password", "database");

// Check if the connection was successful
if (SQL_IsError(database))
{
LogError("Failed to connect to database: %s", SQL_GetLastError());
return;
}

// Create the query string
new query[256];
Format(query, sizeof(query), "INSERT INTO rewards (steamid, points) VALUES ('%s', %d)", steamid, points);

// Execute the query
new result = SQL_Query(database, query);

// Check if the query was successful
if (SQL_IsError(result))
{
LogError("Failed to execute query: %s", SQL_GetLastError());
}

// Free the query result
SQL_FreeResult(result);

// Close the database connection
SQL_Disconnect(database);
}



i am getting these errors
(50) : error 017: undefined symbol "SQL_IsError"
(52) : error 017: undefined symbol "SQL_GetLastError"
(64) : error 017: undefined symbol "SQL_IsError"
(70) : error 017: undefined symbol "SQL_FreeResult"
(73) : error 017: undefined symbol "SQL_Disconnect"

any help would be useful
Attached Files
File Type: sp Get Plugin or Get Source (newplugin.sp - 22 views - 2.0 KB)

Last edited by GhnRyoku; 04-18-2023 at 07:37. Reason: I put it in the wrong section sorry
GhnRyoku is offline
SoulWeaver16
Senior Member
Join Date: May 2021
Location: Uruguay
Old 04-25-2023 , 15:23   Re: [REQUEST] Can someone fix this code that was generated with chatgpt?
Reply With Quote #2

I think it is for SourceMod and they are in the forum for AmxMod
__________________
Extended Arm Weapon Skin v2.1 {16/Apr/23}
(Detect which class is and associate it with the corresponding arms)
SideWeapons v0.2 {01/Sep/22}
(New version of Back Weapons v1.87)

SoulWeaver16 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 16:49.


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