View Single Post
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