AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Spawnmoney jctf (https://forums.alliedmods.net/showthread.php?t=338158)

yagami 06-11-2022 17:49

Spawnmoney jctf
 
Good night I'll try to explain as best I can I'm using JCTF by Digi plugin
in it I made a config like this

Admin starts with 3000 and players with 2000


Code:

pCvar_adm_startmoney = MONEY ADMIN
pCvar_mp_startmoney = MONEY PLAYER

when ADMIN/PLAYER dies without spending anything he comes back with money that was set for him + BONUS SPAWNMONEY but this is not happening

PHP Code:

if(g_bFirstSpawn[id] || g_bRestarted[id])
    {
        
g_bRestarted[id] = false
        g_bFirstSpawn
[id] = false


        
new iStartMoney = (is_user_admin(id) ? get_pcvar_num(pCvar_adm_startmoney) : get_pcvar_num(pCvar_mp_startmoney));
        if (
cs_get_user_money(id) < iStartMoney)
                
cs_set_user_money(idclamp(iStartMoneyget_pcvar_num(pCvar_mp_startmoney), 16000));
    
    }
    else if(
g_bSuicide[id])
    {
        
g_bSuicide[id] = false

        player_print
(idid"%L"id"SPAWN_NOMONEY")
    }
    else
    {

       
// SHOULD NOT THE SPAWN MONEY BONUS HERE?
        
new iStartMoney = (is_user_admin(id) ? get_pcvar_num(pCvar_adm_startmoney) : get_pcvar_num(pCvar_mp_startmoney));
        if (
cs_get_user_money(id) < iStartMoney)
              
cs_set_user_money(idclamp((iStartMoney get_pcvar_num(pCvar_ctf_spawnmoney)), get_pcvar_num(pCvar_mp_startmoney), 16000))
      }        



Supremache 06-11-2022 19:08

Re: Spawnmoney jctf
 
cs_get_user_money( id ) + BONUS SPAWNMONEY

yagami 06-11-2022 19:41

Re: Spawnmoney jctf
 
Quote:

Originally Posted by Supremache (Post 2781504)
cs_get_user_money( id ) + BONUS SPAWNMONEY

PHP Code:

else
    {
        new 
iStartMoney = (is_user_admin(id) ? get_pcvar_num(pCvar_adm_startmoney) : get_pcvar_num(pCvar_mp_startmoney));
        
// if (cs_get_user_money(id) < iStartMoney)
          
cs_set_user_money(idclamp((iStartMoney get_pcvar_num(pCvar_ctf_spawnmoney)), get_pcvar_num(pCvar_mp_startmoney), 16000))
      }        


precisely this is where he gives money + bonus but I can't solve the problem

Supremache 06-11-2022 21:41

Re: Spawnmoney jctf
 
You said in your request that you want to return the money to those who didn't spend it, so why are you still giving them the starter money, try adding their existing money to the spawn money.

PHP Code:

cs_set_user_money(idclamp(( cs_get_user_moneyid ) + get_pcvar_num(pCvar_ctf_spawnmoney)), get_pcvar_num(pCvar_mp_startmoney), 16000)) 


yagami 06-12-2022 10:51

Re: Spawnmoney jctf
 
Quote:

Originally Posted by Supremache (Post 2781512)
You said in your request that you want to return the money to those who didn't spend it, so why are you still giving them the starter money, try adding their existing money to the spawn money.

PHP Code:

cs_set_user_money(idclamp(( cs_get_user_moneyid ) + get_pcvar_num(pCvar_ctf_spawnmoney)), get_pcvar_num(pCvar_mp_startmoney), 16000)) 



Basically this, I want to give extra money to those who haven't spent anything
but there are two cvars there
pCvar_adm_startmoney = ADMIN/VIP MONEY
pCvar_mp_startmoney = PLAYER MONEY

PHP Code:

cs_set_user_money(idclamp(( cs_get_user_moneyid ) + get_pcvar_num(pCvar_ctf_spawnmoney)), get_pcvar_num(pCvar_mp_startmoney), 16000)) 

[/QUOTE] this code here would not be giving money only to players

Supremache 06-12-2022 13:50

Re: Spawnmoney jctf
 
PHP Code:

if (cs_get_user_money(id) >= iStartMoney


yagami 06-12-2022 16:03

Re: Spawnmoney jctf
 
Quote:

Originally Posted by Supremache (Post 2781566)
PHP Code:

if (cs_get_user_money(id) >= iStartMoney



This here seems to work but now I have another problem when I spend my money it doesn't give me back the value I should have from the das cvars

Supremache 06-12-2022 16:58

Re: Spawnmoney jctf
 
Quote:

Originally Posted by yagami (Post 2781572)
This here seems to work but now I have another problem when I spend my money it doesn't give me back the value I should have from the das cvars

Replace
PHP Code:

cs_set_user_money(idclamp(( cs_get_user_moneyid ) + get_pcvar_num(pCvar_ctf_spawnmoney)), get_pcvar_num(pCvar_mp_startmoney), 16000)) 

With
PHP Code:

cs_set_user_money(idclamp(( iStartMoney get_pcvar_num(pCvar_ctf_spawnmoney)), get_pcvar_num(pCvar_mp_startmoney), 16000)) 


yagami 06-12-2022 18:30

Re: Spawnmoney jctf
 
Quote:

Originally Posted by Supremache (Post 2781574)
Replace
PHP Code:

cs_set_user_money(idclamp(( cs_get_user_moneyid ) + get_pcvar_num(pCvar_ctf_spawnmoney)), get_pcvar_num(pCvar_mp_startmoney), 16000)) 

With
PHP Code:

cs_set_user_money(idclamp(( iStartMoney get_pcvar_num(pCvar_ctf_spawnmoney)), get_pcvar_num(pCvar_mp_startmoney), 16000)) 



Still the same thing

Basically it's like this when I spend the money it doesn't return the value of the cvars

EXAMPLE

I have 2000(
HTML Code:

pCvar_mp_startmoney
)

oh I spent 1500 and I only got 500, I just died instead back with 2000, I'm coming back with 500

Supremache 06-12-2022 20:37

Re: Spawnmoney jctf
 
I really dont understand you.
PHP Code:

if (cs_get_user_money(id) >= iStartMoney// If the player did not spend the money
{
// Your code
}
else 
// If the player has spent his money
{
// Your code




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

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