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

Using chatGPT AI to generate scripts and foundations


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Hectik17
AlliedModders Donor
Join Date: Oct 2005
Old 12-18-2022 , 22:29   Using chatGPT AI to generate scripts and foundations
Reply With Quote #1

anyone been messing around with chatGPT
its AI is crazy good for anything, i been messing with it to make batch scripts, translate text, write paragraphs, break down long walls of text to just summarize what its about

its basically a strait to the point google that you can add on the the results to add more code steps or correct a mistake etc.

So i haven't been on the forums for a good ... 6 years, but when i ran a active 1.6 server (30- 50 regular players over 3 years ever night PUGs and during the day funmaps and pub setting) good times.
i basically read through these forums looking at code to make 5v5 team lock plugins, a say /score counter when LO3, that displays simple text [CT-3]-[T-5]
and /rounds to print how many rounds are left, also would announce that its halftime and swap the numbers. this is all besides the point im tryin to make, But i ended up somehow making a plugins with little knowledge on the functions and syntaxs, (a lot of heisenbug type "medicines" were involved every weekend for 3 years. 5 out of 7 days it was GO GO GO time"

i did a lot of custom plugins by basically 3 years of tinkering and cutting. pasting code snippets. im trying to remember it all after 6 years, i think ill get lost if i tryed to even look at the code i did, i could barely grasp it at the time tweaking out i would get lost in sma files L:OL, (i was proud of the achievements)

I should post the sma files for ppl to to break down. only problem i ever had was a small memory leak after like 5 match's, the team lock plugin would bug out. but a quick "amx_cmd restart 1" would fix it. (I think that was the command)

I'm off topic

I told the AI do this:
Quote:
create a amxx plugin using pawn that enables voice chat to both team when spectating and after they die

Code:
#include <amxmodx>
#include <engine>
#include <csx>

new const g_szType[] = "type";
new const g_szTeam[] = "team";

new g_VoiceState[33];

public plugin_init()
{
register_plugin("Voice Chat for Spectators and Dead Players", "1.0", "Your Name");
register_event("DeathMsg", "OnDeath", "a");
register_event("HLTV", "OnSpectatorConnect", "a");
register_event("HLTV", "OnSpectatorDisconnect", "a");
register_event("TextMsg", "OnTextMessage", "a");
}

public OnDeath(id)
{
g_VoiceState[id] = 0;
}

public OnSpectatorConnect(id)
{
g_VoiceState[id] = 1;
}

public OnSpectatorDisconnect(id)
{
g_VoiceState[id] = 0;
}

public OnTextMessage(const id, const szType[], const szString[])
{
if (equal(szType, g_szType) && equal(szString, g_szTeam))
{
if (g_VoiceState[id] == 1)
{
new szTeam[8];
get_user_team(id, szTeam, charsmax(szTeam));

        if (szTeam[0] == 'T')
            set_user_team(id, "CT");
else if (szTeam[0] == 'C')
            set_user_team(id, "T");
    }
    else if (g_VoiceState[id] == 0)
    {
        set_user_team(id, "SPECTATOR");
    }
}
}

I then asked the AI:
Quote:
is this correct
else if (szTeam[0] == 'C')
or is it
else if (szTeam[0] == 'CT')
The AI said:
Quote:
The correct syntax is:
Code:
else if (szTeam[0] == 'CT')


I then told it to:

Quote:
redo whole script but use that correct syntax


Code:
#include <amxmodx>
#include <engine>
#include <csx>

new const g_szType[] = "type";
new const g_szTeam[] = "team";

new g_VoiceState[33];

public plugin_init()
{
register_plugin("Voice Chat for Spectators and Dead Players", "1.0", "Your Name");
register_event("DeathMsg", "OnDeath", "a");
register_event("HLTV", "OnSpectatorConnect", "a");
register_event("HLTV", "OnSpectatorDisconnect", "a");
register_event("TextMsg", "OnTextMessage", "a");
}

public OnDeath(id)
{
g_VoiceState[id] = 0;
}

public OnSpectatorConnect(id)
{
g_VoiceState[id] = 1;
}

public OnSpectatorDisconnect(id)
{
g_VoiceState[id] = 0;
}

public OnTextMessage(const id, const szType[], const szString[])
{
if (equal(szType, g_szType) && equal(szString, g_szTeam))
{
if (g_VoiceState[id] == 1)
{
new szTeam[8];
get_user_team(id, szTeam, charsmax(szTeam));

        if (szTeam[0] == 'T')
            set_user_team(id, "CT");
else if (szTeam[0] == 'CT')
            set_user_team(id, "T");
    }
    else if (g_VoiceState[id] == 0)
    {
        set_user_team(id, "SPECTATOR");
    }
}
}

Im not sure if the AI made mistake or if the code functions, but it looks right.
what can you guys think for the ai to do, i know it would be usful for simple questions on code snipits. any code not just PAwn
Hectik17 is offline
zXCaptainXz
Member
Join Date: May 2017
Old 12-19-2022 , 04:52   Re: Using chatGPT AI to generate scripts and foundations
Reply With Quote #2

Wow... I can't believe the AI wrote all of this, what an age we live in. Even if it's incorrect it's still impressive.

The correct syntax is else if (szTeam[0] == 'C'), because the [0] means the first character (index number 0) of the string. If szTeam = "CT" then szTeam[0]='C' (notice I used double quotes in the first case for strings, and single quotes in the second case for character. It's less computationally expensive to check 1 character instead of checking the whole string (the performance difference is negligible outside of loops though)

EDIT: Oh by the way, just gave the whole plugin a quick read. It basically does nothing and doesn't make too much sense LOL. But still it's so close to being correct.

Last edited by zXCaptainXz; 12-19-2022 at 04:55.
zXCaptainXz is offline
Hectik17
AlliedModders Donor
Join Date: Oct 2005
Old 12-20-2022 , 18:23   Re: Using chatGPT AI to generate scripts and foundations
Reply With Quote #3

well if it does nothing AI still wrote it, id say its good for learning how to approach a plugin you'd want to make or learn the basic functions etc you should give it a go

igot it to make this batch script https://www.veed.io/view/adf7e4f5-f8...34?panel=share
Hectik17 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-20-2022 , 22:29   Re: Using chatGPT AI to generate scripts and foundations
Reply With Quote #4

Quote:
Originally Posted by Hectik17 View Post
well if it does nothing AI still wrote it, id say its good for learning how to approach a plugin you'd want to make or learn the basic functions etc you should give it a go
"if it's wrong it's good" . . . that doesn't make sense. Doesn't matter who wrote it, if it's wrong it's wrong.
__________________
fysiks is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 12-21-2022 , 06:18   Re: Using chatGPT AI to generate scripts and foundations
Reply With Quote #5

Actually the AI is not wrong it's just missing alot of informations, not sure how the AI access each language resources, although it's not bad , here I asked the AI to create user frags displayment after a long dialogue.

The results:
PHP Code:
#include <amxmodx>
#include <cstrike>
#include <nvault>

new g_playerFrags[33]

public 
plugin_init()
{
    
register_plugin("Frag Display""1.0""YourName")
}

public 
client_putinserver(id)
{
    new 
szName[32], szFrags[32]
    
get_user_name(idszName31)
    if (
nvault_get(szName"frags"szFrags31))
    {
        
g_playerFrags[id] = str_to_num(szFrags)
    }
    else
    {
        
g_playerFrags[id] = 0
    
}
    
client_print(idprint_chat"Welcome to the server! Your current frag count is %d."g_playerFrags[id])
}

public 
client_disconnected(id)
{
    new 
szName[32], szFrags[32]
    
get_user_name(idszName31)
    
g_playerFrags[id] += get_user_frags(id)
    
num_to_str(g_playerFrags[id], szFrags31)
    
nvault_set(szName"frags"szFrags)

NGL truly an amazing achievement.

Questions + Fixes I asked the AI to update.

Code:
* Create an amxmodx plugin that display user fragment.

* Use nVault module to save user fragment on disconnect

* Update include name Nvidia to nvault

* Update nvault_set as it takes the third argument ad a string.

* Load user frags from nvault in client_putinserver

* Instead of displaying a welcoming message in client_putinserver save user frags in a global player variable.

* No need to print a message for the client in client_disconnect or client_disconnected forward because it would be already late because the client had already left the server.

* Remove client_disconnect because it is deprecated.

* Set user frags to the global variable g_PlayerFrags in putinserver function.

* Update local variables names with the tag "sz" that are strings

* Amxmodx doesn't support memory manipulation, fix szFrags = g_playerFrags.

* Add user frags to g_playerfrags when converting to a string in client_disconnected
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 12-21-2022 at 06:28.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 12-21-2022 , 06:40   Re: Using chatGPT AI to generate scripts and foundations
Reply With Quote #6

AI source place, GitHub
__________________
Do not Private Message @me
Bacardi 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 08:09.


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