AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Update user money (https://forums.alliedmods.net/showthread.php?t=347238)

tedaimlocks 04-13-2024 14:23

Update user money
 
As the title says, can anyone help create a plugin to use a buymenu natives to update the money in score tab?

The natives are:
zp_cs_get_user_money(id)
zp_cs_set_user_money(id)

Pic of what i mean and smaller explaination
https://imgur.com/a/BLwG6dh

- Get user money using zp_cs_get_user_money(id) and set it in TAB using zp_cs_set_user_money(id)

tedaimlocks 04-14-2024 06:46

Re: Update user money
 
solved. for anyone who needs the plugin :

PHP Code:

#include <amxmodx>
#include <cstrike>
#include <zp_buymenu>

#define PLUGIN "Money convert"
#define VERSION "1.0"
#define AUTHOR "tedaimlocks"

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
set_task(10.0"loop_client_putinserver"0""0"b");
}

public 
loop_client_putinserver()
{
    new 
id;
    for(
id 1id <= get_maxplayers(); id++)
    {
        if(
is_user_connected(id))
        {
            
client_putinserver(id);
        }
    }
    return 
PLUGIN_HANDLED;
}

public 
client_putinserver(id) {
    if (!
is_user_connected(id) || is_user_bot(id))
        return 
PLUGIN_CONTINUE
   
    
cs_set_user_money(idzp_cs_get_user_money(id));
    return 
PLUGIN_HANDLED;



mlibre 04-14-2024 09:01

Re: Update user money
 
Quote:

Originally Posted by tedaimlocks (Post 2820939)
solved. for anyone who needs the plugin :

wtf

hi, I guess you're you are trying to restore the money to the player "only" when he connects to the server, this would be done once therefore it is not necessary to create an infinite loop since it recreates an overload to the server and more if it is a zp :nono:

for them we can make sure that the player has entered and chosen a team, and then give them the money.

It will be enough, try...

Code:
#include <amxmodx> #include <hamsandwich> #include <cstrike> #include <zp_buymenu> #if AMXX_VERSION_NUM > 182     #define client_disconnect client_disconnected #else     #define MAX_PLAYERS 32 #endif new bool:is_spawn[MAX_PLAYERS + 1] public plugin_precache() {     RegisterHam(Ham_Spawn, "player", "Ham_SpawnPlayer_Post", true) } public Ham_SpawnPlayer_Post(id) {     if( !is_spawn[id] && is_user_alive(id) )     {         is_spawn[id] = true                 cs_set_user_money(id, zp_cs_get_user_money(id))     } } public client_putinserver(id) {     if(is_user_bot(id))     {         is_spawn[id] = true     } } public client_disconnect(id) {     if(is_spawn[id])     {         is_spawn[id] = false     } }


All times are GMT -4. The time now is 21:16.

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