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

Zephyrus's store refresh client inventory


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GetRektByNoob
Member
Join Date: Nov 2018
Old 07-24-2019 , 17:09   Zephyrus's store refresh client inventory
Reply With Quote #1

Hey everyone,
I'm using the Zephyrus store and I'm giving items to players using SQL, the problem is that when I give someone an item he needs to retry to see the item in his inventory, so I need to refresh his inventory.
I looked at the natives and there is no native to refresh the client's inventory.
so so I looked at the code and there is a function that loads the client's inventory.
The problem is that I can't include the store.sp file to my file because both of the files have forwards that are used twice like OnPluginStart.

does anyone have an idea, how can refresh the client inventory?
GetRektByNoob is offline
alex2001
Member
Join Date: May 2019
Old 08-07-2019 , 13:47   Re: Zephyrus's store refresh client inventory
Reply With Quote #2

you give item custom or item who already has in store?
if item already you can try store_giveitem native or store_giveclientitem

Last edited by alex2001; 08-07-2019 at 13:48.
alex2001 is offline
GetRektByNoob
Member
Join Date: Nov 2018
Old 08-08-2019 , 16:28   Re: Zephyrus's store refresh client inventory
Reply With Quote #3

i would but this functions use ItemID and i dont know how to get it
GetRektByNoob is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 08-22-2019 , 04:08   Re: Zephyrus's store refresh client inventory
Reply With Quote #4

PHP Code:
public Native_ForceSaveClientData(Handle:pluginnumParams)
{
    
/* Save all the data like in OnClientDisconnect, just in case? */
    
Store_SaveClientData(GetNativeCell(1));
    
Store_SaveClientInventory(GetNativeCell(1));
    
Store_SaveClientEquipment(GetNativeCell(1));
    return 
1;
}

public 
Native_ReloadClientInventory(Handle:pluginnumParams)
{
    
/* (Re-)load inventory stuff... */
    
Store_LoadClientInventory(GetNativeCell(1));
    return 
1;

^ Simply made with the "coding style" of natives, et cetera, from the current store from github.com/dvarnai/store-plugin .


Add:

PHP Code:
    CreateNative("Store_ForceSaveClientData"Native_ForceSaveClientData);
    
CreateNative("Store_ReloadClientInventory"Native_ReloadClientInventory); 

within the procedure called:
PHP Code:
public APLRes:AskPluginLoad2(Handle:myselfbool:lateString:error[], err_max

Add:
PHP Code:
native Store_ForceSaveClientData(client);
native Store_ReloadClientInventory(client); 
to addons/sourcemod/scripting/include/store.inc.


1. Make the adjustments (in store.sp & include/store.inc).

2. Re-compile Store


To use( in your plugin):

Quote:
Originally Posted by GetRektByNoob View Post
The problem is that I can't include the store.sp file to my file [...]
You have to to stuff like e.g.
PHP Code:
#include <store> 
in your plugin, to be able to use the natives from Store.

Then do things in this order:

1. Run Store_ForceSaveClientData(client), to save the client's current credits/inventory, just in case.

2. Modify your stuff in the database, the way you currently do.

3. Run Store_ReloadClientInventory(client)


Store_ForceSaveClientData is done due to the way Store works with in-plugin caching of credits, and in order to prevent the client form losing too many credits or so during your feature.

You could potentially just do Store_ReloadClientInventory, but the user would then lose all credits and so that has happened since last time Store saved the user's data, therefore, please be sane, and do it in the above order.


PROVIDED WITH ABSOLUTELY NO GUARANTEE OR SUPPORT.
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].

Last edited by DarkDeviL; 08-22-2019 at 10:01. Reason: Added addons/sourcemod/scripting/include/store.inc adjustments.
DarkDeviL is offline
GetRektByNoob
Member
Join Date: Nov 2018
Old 08-22-2019 , 09:20   Re: Zephyrus's store refresh client inventory
Reply With Quote #5

I'm kind of confused since I haven't touched all the natives thing...
I added this 2 blocks to the sp file
PHP Code:
public Native_ForceSaveClientData(Handle:pluginnumParams

    
/* Save all the data like in OnClientDisconnect, just in case? */ 
    
Store_SaveClientData(GetNativeCell(1)); 
    
Store_SaveClientInventory(GetNativeCell(1)); 
    
Store_SaveClientEquipment(GetNativeCell(1)); 
    return 
1


public 
Native_ReloadClientInventory(Handle:pluginnumParams

    
/* (Re-)load inventory stuff... */ 
    
Store_LoadClientInventory(GetNativeCell(1)); 
    return 
1

PHP Code:
    CreateNative("Store_ForceSaveClientData"Native_ForceSaveClientData); 
    
CreateNative("Store_ReloadClientInventory"Native_ReloadClientInventory); 
and compiled it, and it created smx file which is great.

now I don't understand what to include? in my plugin currently, I'm including the inc file and not the sp file... I need to include the sp file or the smx? (pretty sure it's not possible to include smx file but ima ask anyway xD)

and I have side question, doing this method means that anyone who wants to use my plugin needs to download this store version?
__________________
𝓓𝓲𝓼𝓬𝓸𝓻𝓭 » GetRektByNoob#5272
𝓢𝓽𝓮𝓪𝓶 » https://steamcommunity.com/profiles/76561198805764302/
GetRektByNoob is offline
ShD3luxe
Member
Join Date: Aug 2019
Location: Localhost
Old 08-22-2019 , 09:29   Re: Zephyrus's store refresh client inventory
Reply With Quote #6

You can do in the plugin u want to use the natives(if you don't have an inc file or you just don't want to create one) :

native Store_ForceSaveClientData(client);
native Store_ReloadClientInventory(client);

But I think those(the code for creating the natives) need to be added in the zephyrus store and u can just include that inc ( be sure to add the natives in the include too ) . Also yes , they need to have your version.

Last edited by ShD3luxe; 08-22-2019 at 09:30.
ShD3luxe is offline
GetRektByNoob
Member
Join Date: Nov 2018
Old 08-22-2019 , 09:52   Re: Zephyrus's store refresh client inventory
Reply With Quote #7

so i need to add
PHP Code:
public Native_ForceSaveClientData(Handle:pluginnumParams)  
{  
    
/* Save all the data like in OnClientDisconnect, just in case? */  
    
Store_SaveClientData(GetNativeCell(1));  
    
Store_SaveClientInventory(GetNativeCell(1));  
    
Store_SaveClientEquipment(GetNativeCell(1));  
    return 
1;  
}  

public 
Native_ReloadClientInventory(Handle:pluginnumParams)  
{  
    
/* (Re-)load inventory stuff... */  
    
Store_LoadClientInventory(GetNativeCell(1));  
    return 
1

and
PHP Code:
CreateNative("Store_ForceSaveClientData"Native_ForceSaveClientData); 
CreateNative("Store_ReloadClientInventory"Native_ReloadClientInventory); 
to the store.sp file and add

PHP Code:
native Store_ForceSaveClientData(client); 
native Store_ReloadClientInventory(client); 
to my own .inc file or to the store.inc file (lets say StoreClientInventory.inc)

and last include the StoreClientInventory.inc file in the store plugin and my plugin
__________________
𝓓𝓲𝓼𝓬𝓸𝓻𝓭 » GetRektByNoob#5272
𝓢𝓽𝓮𝓪𝓶 » https://steamcommunity.com/profiles/76561198805764302/
GetRektByNoob is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 08-22-2019 , 09:59   Re: Zephyrus's store refresh client inventory
Reply With Quote #8

Quote:
Originally Posted by GetRektByNoob View Post
and I have side question, doing this method means that anyone who wants to use my plugin needs to download this store version?
Yes, everyone will need the modified store to be able to use them.

Should I run your plugin, I would also have to perform those changes to the Store I run.

Quote:
Originally Posted by ShD3luxe View Post
native Store_ForceSaveClientData(client);
native Store_ReloadClientInventory(client);
+1.

Forgot those in my quick-writing...

Quote:
Originally Posted by GetRektByNoob View Post
PHP Code:
native Store_ForceSaveClientData(client); 
native Store_ReloadClientInventory(client); 
to my own .inc file or to the store.inc file (lets say StoreClientInventory.inc)

and last include the StoreClientInventory.inc file in the store plugin and my plugin
No, add those two native ones to: addons/sourcemod/scripting/include/store.inc.

When you then do "#include <store>" in the top of your own plugin, your own plugin will know the new two commands.
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL is offline
ShD3luxe
Member
Join Date: Aug 2019
Location: Localhost
Old 08-22-2019 , 10:00   Re: Zephyrus's store refresh client inventory
Reply With Quote #9

Exactly.But you don't need to include the inc file in the store plugin just in your plugin. Also do the steps Devil mentioned when you use those natives in your plugin .
Code:
1. Call Store_ForceSaveClientData(client), to save the client's current credits/inventory, just in case.

2. Modify your stuff in the database, the way you currently do.

3. Call Store_ReloadClientInventory(client)
ShD3luxe is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 08-22-2019 , 10:05   Re: Zephyrus's store refresh client inventory
Reply With Quote #10

Quote:
Originally Posted by ShD3luxe View Post
Exactly.But you don't need to include the inc file in the store plugin just in your plugin. Also do the steps Devil mentioned when you use those natives in your plugin .
Not directly with "store.inc", no.

Simply do "#include <store>", once the two native lines are added include/store.inc as I confirmed above, and it'll be all right.
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL 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 14:51.


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