Raised This Month: $ Target: $400
 0% 

Get Players Money at Disconnect throws error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 05-05-2013 , 15:57   AW: Get Players Money at Disconnect throws error
Reply With Quote #1

Then I'm sorry, I'll look later for Money event.
Thanks for the help.
__________________
Kia is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-05-2013 , 19:59   Re: Get Players Money at Disconnect throws error
Reply With Quote #2

Retrieve pdata should work.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Leon M.
Senior Member
Join Date: Apr 2009
Location: Germany
Old 05-06-2013 , 00:22   Re: Get Players Money at Disconnect throws error
Reply With Quote #3

Quote:
Originally Posted by Kia View Post
Hello everybody,

I have a little problem here, I wan't to save the players money into a Variable when he's disconnecting using this code :

PHP Code:
public client_disconnect(id)
{
    
g_iMoney[id] = cs_get_user_money(id// Error Line
    
save_user_money(id)    

But sometimes I get this in my log and players saved money gets 0 :

Anyone knows how to fix that? I'd say "if(is_user_connected(id))", but I think I can't check that on disconnect.

Greets,
Kia.
A lil' bit offtopic since you got your solution with the money event but maybe you are interested why this is happening.


As you stated it occurs sometimes and not all the time. We had recently a hot discussion about removing a task on client_disconnect. I tried to explain that it is not entirely secure if a task includes functions like cs_get_user_money/team and you don't check for is_user_connected inside of the tasked function. This is happening due to the fact of a time window, some guys are saying it is unimportant since it is "a fraction of a second" but the time window is existent as you recognized.
__________________
  • ZapTic - Paintball (Version 7.1.3 b1303)
  • Your #1 CS Paintball Server since 2008
  • 85.131.163.101:27015
Leon M. is offline
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 05-06-2013 , 02:43   Re: Get Players Money at Disconnect throws error
Reply With Quote #4

I try this code now :

PHP Code:
if(is_user_connected(id))
    {
        
g_iMoney[id] = cs_get_user_money(id)
        
save_user_money(id)
    } 
Money is still saving, so I think you're right with
Quote:
"a fraction of a second" but the time window is existent as you recognized.
__________________
Kia is offline
Leon M.
Senior Member
Join Date: Apr 2009
Location: Germany
Old 05-06-2013 , 12:56   Re: Get Players Money at Disconnect throws error
Reply With Quote #5

Although I love to see that someone agrees to my statement (... finally ^^) I hope you just did it for testing purpose. You should really receive the money through the "money" event and save it into a global variable because the current method is not working properly enough.

If you need help with the event then I'll be glad to help you. Just PM me
__________________
  • ZapTic - Paintball (Version 7.1.3 b1303)
  • Your #1 CS Paintball Server since 2008
  • 85.131.163.101:27015
Leon M. is offline
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 05-06-2013 , 14:35   AW: Get Players Money at Disconnect throws error
Reply With Quote #6

I tested the method above, no changes, sometimes the money even disappears while player is connected.
__________________
Kia is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 05-06-2013 , 15:49   Re: Get Players Money at Disconnect throws error
Reply With Quote #7

Use a trie cells and SteamIDs, its more easy..

For users id not work when other player connects in server its will replace a old player id

:0
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Leon M.
Senior Member
Join Date: Apr 2009
Location: Germany
Old 05-06-2013 , 19:45   Re: Get Players Money at Disconnect throws error
Reply With Quote #8

It depends on his save feature. If he is using any vault database then the storage should be fast enough to store properly. If he is using a threaded sql query then you are right
__________________
  • ZapTic - Paintball (Version 7.1.3 b1303)
  • Your #1 CS Paintball Server since 2008
  • 85.131.163.101:27015
Leon M. is offline
yokomo
Surprise Ascot!
Join Date: May 2010
Location: Malaysia
Old 05-07-2013 , 00:56   Re: Get Players Money at Disconnect throws error
Reply With Quote #9

Use get_pdata_int
PHP Code:
#include <amxmodx>
#include <fakemeta>

const PDATA_SAFE 2
const OFFSET_CSMONEY 115

fm_cs_get_user_money
(id)
{
    if(
pev_valid(id) != PDATA_SAFE) return -1;
    return 
get_pdata_int(idOFFSET_CSMONEY);

Should work fine.
__________________
Team-MMG CS1.6 Servers:
✅ MultiMod -- 103.179.44.152:27016
✅ Zombie Plague -- 103.179.44.152:27015
✅ Zombie Escape -- 103.179.44.152:27017
✅ Klassik Kombat -- 103.179.44.152:27018
✅ Boss-Battle -- 103.179.44.152:27019

Last edited by yokomo; 05-09-2013 at 14:41. Reason: Thanks Arkshine for inform me :)
yokomo is offline
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 05-07-2013 , 05:05   Re: Get Players Money at Disconnect throws error
Reply With Quote #10

Tried this, but now all players have $0 when they connect.
__________________
Kia 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 10:52.


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