AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   help with adding (https://forums.alliedmods.net/showthread.php?t=335709)

itoxicreal 12-26-2021 16:26

help with adding
 
Hey can anyone help me add
zp_cs_set_user_money(id, zp_cs_get_user_money(id) + Values[value]);
zp_set_user_exp(id, zp_get_user_exp(id) + Exps[exp]);
in 1 line?

and edit the client print msg

client_print(id, print_chat, "[ZP] You have just received %d $ and %d exp, try again after map change!", Values[value]);


PHP Code:

#include <amxmodx>
#include <zombieplague>

new bool:g_HasMoneynEXP[33] = false;

new const 
GET_CSO[][] = {
    
    
"say /get",
    
"say_team /get"
}

new 
Values[6] = {

    
20000
    
35000,
    
45000,
    
50000,
    
60000,
    
100000
}
new 
Exps[6] = {

    
200
    
400,
    
600,
    
800,
    
1000,
    
1500
}

public 
plugin_init() {    
    
register_cvar("cso_get"VERSIONFCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)

    for (new 
isizeof GET_CSOi++)
    
register_clcmd(GET_CSO[i], "give_money_exp");
}

public 
plugin_natives()
{
    
register_native("zp_cs_get_user_money""_get_money"1)
    
register_native("zp_cs_set_user_money""native_set_money"1)
    
register_native("zp_get_user_exp""native_get_exp"1)
    
register_native("zp_set_user_exp""native_set_exp"1)
}

public 
give_money_exp(id) {
    
    if(
g_HasMoneynEXP[id]) {
        
client_print(idprint_chat"[CSO] Retry again after map changes to get more Money&Exp!");
        return 
PLUGIN_HANDLED;
    }
    
    new 
value random_num(20000100000)
    new 
exp random_num(2001500)
    
zp_cs_set_user_money(idzp_cs_get_user_money(id) + Values[value]);
    
zp_set_user_exp(idzp_get_user_exp(id) + Exps[exp]);
    
client_print(idprint_chat"[CSO]  You have just received %d $ and  exp, try again after map change!"Values[value], Exps[exp]);
    
g_HasMoneynEXP[id] = true;
    
    return 
PLUGIN_HANDLED;



OciXCrom 12-26-2021 16:28

Re: help with adding
 
I don't understand what you mean by that.

itoxicreal 12-26-2021 18:19

Re: help with adding
 
the plugin dosent work and those things are causing it, so if someone can fix it, it would mean alot

Supremache 12-26-2021 18:52

Re: help with adding
 
Quote:

Originally Posted by itoxicreal (Post 2767006)
the plugin dosent work and those things are causing it, so if someone can fix it, it would mean alot

Create the natives ex: native zp_cs_get_user_money( id ), native zp_cs_set_user_money( id, amount )
Code:
public plugin_natives() {     register_native("zp_cs_get_user_money", "_get_money", 1)     register_native("zp_cs_set_user_money", "native_set_money", 1)     register_native("zp_get_user_exp", "native_get_exp", 1)     register_native("zp_set_user_exp", "native_set_exp", 1) } public give_money_exp(id) {         if(g_HasMoneynEXP[id]) {         client_print(id, print_chat, "[CSO] Retry again after map changes to get more Money&Exp!");         return PLUGIN_HANDLED;     }         new value = random_num(20000, 100000)     new exp = random_num(200, 1500)  it is not possible to use native from register     zp_cs_set_user_money(id, zp_cs_get_user_money(id) + Values[value]);     zp_set_user_exp(id, zp_get_user_exp(id) + Exps[exp]);     client_print(id, print_chat, "[CSO]  You have just received %d $ and  exp, try again after map change!", Values[value], Exps[exp]);     g_HasMoneynEXP[id] = true;         return PLUGIN_HANDLED; }

Show "_get_money" function

Edit: if the plugin already has these native or include then no one can help you without see the full code

itoxicreal 12-28-2021 15:06

Re: help with adding
 
sorry the natives weren't meant to be there


PHP Code:

#include <amxmodx>
#include <zombieplague>
#include <zp_buys>

new bool:g_HasMoneynEXP[33] = false;

new const 
GET_CSO[][] = {
    
    
"say /get",
    
"say_team /get"
}

new 
Values[6] = {

    
20000
    
35000,
    
45000,
    
50000,
    
60000,
    
100000
}
new 
Exps[6] = {

    
200
    
400,
    
600,
    
800,
    
1000,
    
1500
}

public 
plugin_init() {    
    
register_cvar("cso_get"VERSIONFCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)

    for (new 
isizeof GET_CSOi++)
    
register_clcmd(GET_CSO[i], "give_money_exp");
}

public 
give_money_exp(id) {
    
    if(
g_HasMoneynEXP[id]) {
        
client_print(idprint_chat"[CSO] Retry again after map changes to get more Money&Exp!");
        return 
PLUGIN_HANDLED;
    }
    
    new 
value random_num(20000100000)
    new 
exp random_num(2001500)
    
zp_cs_set_user_money(idzp_cs_get_user_money(id) + Values[value]);
    
zp_set_user_exp(idzp_get_user_exp(id) + Exps[exp]);
    
client_print(idprint_chat"[CSO]  You have just received %d $ and  exp, try again after map change!"Values[value], Exps[exp]);
    
g_HasMoneynEXP[id] = true;
    
    return 
PLUGIN_HANDLED;


plugin compiles fine but when I use it the console says (debug is enabled but it says enable still)

[AMXX] Run time error 19 (plugin "zp_get.amxx") - debug not enabled!
L 12/28/2021 - 15:05:33: [AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quotes).
L 12/28/2021 - 15:05:33: [AMXX] Run time error -1 (plugin "zp_get.amxx") - debug not enabled!
L 12/28/2021 - 15:05:33: An error occurred in plugin_natives. This is dangerous!

Supremache 12-28-2021 15:31

Re: help with adding
 
Enable debug and back with message logs or show the wrong in which line

bigdaddy424 12-29-2021 09:17

Re: help with adding
 
Try this
zp_cs_set_user_money(id, zp_cs_get_user_money(id) + Values[random_num(0, sizeof(Values) - 1)])

Supremache 12-29-2021 11:18

Re: help with adding
 
@itoxicreal; the wrong was in the line of client_print, there are two values, "Values[value] & Exps[exp]" with just one field %d also you didn't use register_plugin !

PHP Code:

client_print(idprint_chat"[CSO]  You have just received %d $ and  exp, try again after map change!"Values[value], Exps[exp]); 

PHP Code:

#include <amxmodx>
#include <zombieplague>
#include <zp_buys>

new bool:bReward33 ]

new const 
GET_CSO[ ][ ] = 
{
    
"say /get",
    
"say_team /get"
}

enum GetReward
{
    
Value,
    
Exp
}

new 
g_szReward[ ][ GetReward ] =
{
    { 
20000200 },
    { 
35000400 },
    { 
45000600 },
    { 
50000800 },
    { 
600001000 },
    { 
1000001500 }
}

public 
plugin_init( ) 
{    
    
register_plugin"Get random reward"VERSION"Supremache" );
    
    for (new 
isizeof GET_CSOi++)
        
register_clcmdGET_CSO[i], "GetReward" );
}

public 
GetRewardid 
{
    if( 
bRewardid ] ) 
    {
        
client_printidprint_chat"[CSO] Retry again after map changes to get more Money&Exp!" );
    }
    else
    {
        new 
iValue g_szRewardrandomsizeofg_szReward ) ) ][ Value 
        new 
iExp g_szRewardrandomsizeofg_szReward ) ) ][ Exp ]
        
zp_cs_set_user_moneyidzp_cs_get_user_money(id) + iValue );
        
zp_set_user_expidzp_get_user_exp(id) + iExp );
        
client_printidprint_chat"[CSO] You have just received $%d and %d exp, try again after map change!"iValueiExp );
        
bRewardid ] = true;
    }
    return 
PLUGIN_HANDLED;



itoxicreal 12-29-2021 15:09

Re: help with adding
 
Everything worked out fine, there was just a issue with the Exp giving 0 but i fixed it, I also added cromchat if anyone wanted here is the final version


PHP Code:

#include <amxmodx>
#include <zombieplague>
#include <zp_buys>
#include <cromchat>

#define VERSION "1.0"
#define AUTHOR "unknown"

new bool:g_HasMoneynEXP[33] = false;

new const 
GET_CSO[ ][ ] = {
    
    
"say /get",
    
"say_team /get"
}

enum GetReward
{
    
Value
}

enum GetExp
{
    
Exp
}

new 
g_szReward[ ][GetReward] =
{
    
45000,
    
50000
    
60000,
    
100000
    
120000
    
200000
}
new 
g_szExp[ ][GetExp] =
{
    
500,
    
700
    
800,
    
900
    
1200
    
2000
}


public 
plugin_init( ) 
{    
    
register_plugin"cso_get"VERSION"Author" );
    
register_cvar("cso_get"VERSIONFCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)

    for (new 
isizeof GET_CSOi++)
        
register_clcmd(GET_CSO[i], "give_money_exp");
}

public 
give_money_exp(id) {
    
    if( 
g_HasMoneynEXPid ] ) 
    {
        
CC_SendMessage(id"&x07[CSO] Retry again after map changes to get more Money and Exp!");
        return 
PLUGIN_HANDLED;
    }
    
    new 
iValue g_szRewardrandomsizeofg_szReward ) ) ][ Value 
    new 
iExp g_szExprandomsizeofg_szExp ) ) ][ Exp ]
    
zp_cs_set_user_moneyidzp_cs_get_user_money(id) + iValue );
    
zp_set_user_exp(idzp_get_user_exp(id) + iExp );
    
CC_SendMessageid"&x04[CSO] You have just received $%d and %d exp, try again after map change!"iValueiExp );
    
g_HasMoneynEXPid ] = true;
    
    return 
PLUGIN_HANDLED;



Supremache 12-29-2021 16:20

Re: help with adding
 
Quote:

Originally Posted by itoxicreal (Post 2767222)
Everything worked out fine, there was just a issue with the Exp giving 0 but i fixed it, I also added cromchat if anyone wanted here is the final version

Ops i forgot to add symbol '{' to the array, try it now


All times are GMT -4. The time now is 11:30.

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