AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Saving what a user decides on a menu (https://forums.alliedmods.net/showthread.php?t=75654)

PvtSmithFSSF 08-09-2008 16:29

Saving what a user decides on a menu
 
Well I know how to make a menu where it says "New Guns" like CSDM or zombie infection, and I know how to work the whole menus thing.
BUT.. Here's my idea:
A user types /createNAME replacing NAME with anything they want.
Then a menu comes up like the csdm gun menu.
Then, every time they user logs back on they type /NAME which is whatever they put where they did /createNAME and the guns they chose is given.

For example - I type /createMYGUNS.
Gun menu comes up like CSDM and I choose ak47, deagle, all nades.
Then I leave server. Come back tomorrow or something and type /MYGUNS and get ak47,deagle,all nades.

I know how to do menus, and hook say, and all that but where it saves what they named the pack and then actually saving it that gets me.

Is it possible?

Emp` 08-09-2008 18:11

Re: Saving what a user decides on a menu
 
Yes it's possible.

When you are detecting what they said, you have a string (let's call it said)
Code:

if( equal( said, "/create", 7 ) ){
    //they are trying to create somethign

    //lets get rid of the "/create" part
    copy( said, 127, said[8] );

    //said now contains the part after create
}

Now saving it, I don't know how the guns menus work, but i'll assume you can save the values into a string and load it from a string. So lets say we are trying to save "ak47 deagle all_nades". And we'll pretend that is stored in a string called my_weaps.

Now you can save it in either with vault or nvault (i'll be showing vault because it is slightly easier, but also slower)
Code:

        new vaultSaveKey[40], authid[32];
        get_user_authid(id, authid, 31);
        formatex(vaultSaveKey,39,"MyGuns-%s-%s", authid, said);
        set_vaultdata(vaultSaveKey, my_weaps)

and to load it
Code:

        new his_weaps[150];
        new vaultSaveKey[40], authid[32];
        get_user_authid(id, authid, 31);
        formatex(vaultSaveKey,39,"MyGuns-%s-%s", authid, said);
        get_vaultdata(vaultSaveKey, his_weaps, 150);

his_weaps should be "ak47 deagle all_nades"

PvtSmithFSSF 08-09-2008 18:33

Re: Saving what a user decides on a menu
 
so much confusing code but I'm working on it
thanks a lot

IneedHelp 08-09-2008 18:53

Re: Saving what a user decides on a menu
 
And how to give the weapons that are saved?

I mean...if ak47 deagle all_nades is saved, when the user connects, how to give that weapon and not another weapont, isn't more hard?


All times are GMT -4. The time now is 05:33.

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