AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help me with this little problem [xpsystem] ;-; (https://forums.alliedmods.net/showthread.php?t=326868)

LaranjoBreks 08-20-2020 17:44

Help me with this little problem [xpsystem] ;-;
 
Hello I have a problem with my cs1.6 plugin, I wanted to make a way to block the class choice after choosing it for the first time, example I already chose the class and in the same round I wanted it not to be possible to choose another class unless it is in the next round

Shadows Adi 08-20-2020 19:04

Re: Help me with this little problem [xpsystem] ;-;
 
Declare a new boolean which is holding MAX_PLAYERS + 1 cells and sets it's value true when a class is selected, then check if the boolean exists. After all, remove the bool value in the round start event.

LaranjoBreks 08-20-2020 19:21

Re: Help me with this little problem [xpsystem] ;-;
 
Quote:

Originally Posted by Shadows Adi (Post 2714962)
Declare a new boolean which is holding MAX_PLAYERS + 1 cells and sets it's value true when a class is selected, then check if the boolean exists. After all, remove the bool value in the round start event.

can you teach me how i do this in my code ?

OciXCrom 08-20-2020 20:54

Re: Help me with this little problem [xpsystem] ;-;
 
Where is "your code"?..

LaranjoBreks 08-20-2020 21:11

Re: Help me with this little problem [xpsystem] ;-;
 
Quote:

Originally Posted by OciXCrom (Post 2714971)
Where is "your code"?..

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <nvault>
#include <fun>
#include <cstrike>
#define MAXCLASSES 5
new const CLASSES[MAXCLASSES][] = {
    
"Padrao",
    
"Soldado",
    
"Cabo",
    
"General",
    
"Heroi de Guerra"
}
new const 
LEVELS[6] = {
    
100
    
200
    
400
    
800,
    
1600,
    
3200
}
new 
PlayerXP[33],PlayerLevel[33],PlayerClass[33]
new 
XP_Kill,XP_Knife,XP_Hs,SaveXP,g_vault
public plugin_init()
{
    
register_plugin("XPSYSTEM""2.0""LaranjoBreks")
 
    
register_event("DeathMsg""eDeath""a"
 
    
SaveXP register_cvar("SaveXP","1")
    
XP_Kill=register_cvar("XP_per_kill""20")
    
XP_Hs=register_cvar("XP_hs_bonus","50")
    
XP_Knife=register_cvar("XP_knife_bonus","100")
    
g_vault nvault_open("animod")
 
    
register_clcmd("say /class""ChangeClass")
    
register_clcmd("say_team /class""ChangeClass")
    
register_clcmd("say /xp""ShowHud")
    
register_clcmd("say_team /xp""ShowHud")
}
public 
plugin_precache(){
    
    
precache_model("models/player/Asasin/Asasin.mdl")
    
precache_model("models/player/Death/Death.mdl")
    
precache_model("models/player/Dobby/Dobby.mdl")
    
precache_model("models/player/Sonic/Sonic.mdl")
}
public 
eDeath() 
{
    new 
attacker read_data)
    new 
headshot read_data)
    new 
clipammoweapon get_user_weapon(attacker,clip,ammo);
 
    
PlayerXP[attacker] += get_pcvar_num(XP_Kill)
 
    if(
headshot){
    
PlayerXP[attacker] += get_pcvar_num(XP_Hs)
}
    if(
weapon == CSW_KNIFE){
    
PlayerXP[attacker] += get_pcvar_num(XP_Knife)
}
 
    while(
PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]])
    {
      
client_print(attackerprint_chat"[Animal Mod] Congratulations! You are a level %i %s!",
      
PlayerLevel[attacker] += 1)
    }
    
ShowHud(attacker)
    
SaveData(attacker)
}
public 
ShowHud(id)
{
    
set_hudmessage(255000.750.0106.015.0)
    
show_hudmessage(id"Level: %i^nXP: %i^nClass: %s",PlayerLevel[id],PlayerXP[id],CLASSES[PlayerClass[id]])
}
public 
ChangeClass(id)
{
    new 
menu menu_create("Class Menu" "Class_Handle");
    
menu_additem(menu ,"Soldado = 120 XP""1" 0);
    
menu_additem(menu ,"Cabo = 260 XP""2" 0);
    
menu_additem(menu ,"General = 1000 XP""3" 0);
    
menu_additem(menu ,"Heroi de Guerra = 2400 XP""4" 0);
 
    
menu_setprop(menu MPROP_EXIT MEXIT_ALL);
 
    
menu_display(id menu 0);
}
public 
Class_Handle(id menu item
{
    if(
item == MENU_EXIT
    {
 
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED
    
}
 
    new 
szCommand[5], szName[64];
    new 
access callback;
 
    
menu_item_getinfo(menu item access szCommand szName 63 callback);
 
    new 
str_to_num(szCommand)
    switch(
i)
    {
    case 
1:{
        if(
PlayerXP[id] <= 120){
    
client_print(idprint_chat"Voce nao possui xp suficiente ou ja possui a classe")
    }
    else{
    
set_user_armor(id100)
    
set_user_health(id150)
    
cs_set_user_model(id"Dobby")
    
client_print(id,print_chat,"Voce Escolheu a classe %s",CLASSES[i])
    
PlayerClass[id] = i
    
}
    return 
PLUGIN_HANDLED
    
}
    case 
2:{
    if(
PlayerXP[id] <= 260){
    
client_print(idprint_chat"Voce nao possui xp suficiente ou ja possui a classe")
    }
    else{
    
set_user_armor(id150)
    
set_user_health(id200)
    
cs_set_user_model(id"Sonic")
    
client_print(id,print_chat"Voce Escolheu a classe %s",CLASSES[i])
    
PlayerClass[id] = i
    
}
    return 
PLUGIN_HANDLED
   
}
    case 
3:{
        if(
PlayerXP[id] <= 1000){
    
client_print(idprint_chat"Voce nao possui xp suficiente ou ja possui a classe")
    }
    else{
    
set_user_armor(id200)
    
set_user_health(id250)
    
cs_set_user_model(id"Death")
    
client_print(id,print_chat"Voce Escolheu a classe %s",CLASSES[i])
    
PlayerClass[id] = i
    
}
    return 
PLUGIN_HANDLED
    
}
    case 
4:{
        if(
PlayerXP[id] <= 2400){
    
client_print(idprint_chat"Voce nao possui xp suficiente ou ja possui a classe")
    }
    else{
    
give_item(id,"weapon_ak47")
    
give_item(id,"weapon_deagle")
    
set_user_health(id,350)
    
set_user_armor(id,250)
    
cs_set_user_bpammo(id,CSW_AK47,90)
    
cs_set_user_bpammo(id,CSW_DEAGLE,35)
    
cs_set_user_model(id"Asasin")
    
client_print(id,print_chat,"Voce Escolheu a classe %s",CLASSES[i])
    
PlayerClass[id] = i
    
}
    }
}
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED
}
public 
client_connect(id)
{
    if(
get_pcvar_num(SaveXP) == 1)
    {
 
        
LoadData(id)
    }
}
public 
client_disconnect(id)
{
    if(
get_pcvar_num(SaveXP) == 1)
    {
 
        
SaveData(id)
    }
    
PlayerXP[id] = 0
    PlayerLevel
[id] = 0
    PlayerClass
[id] = 0
}
public 
SaveData(id)
{
    new 
AuthID[35]
    
get_user_authid(id,AuthID,34)
 
    new 
vaultkey[64],vaultdata[256]
    
format(vaultkey,63,"%s-Mod",AuthID)
    
format(vaultdata,255,"%i#%i#",PlayerXP[id],PlayerLevel[id],PlayerClass[id])
    
nvault_set(g_vault,vaultkey,vaultdata)
    return 
PLUGIN_CONTINUE
}
public 
LoadData(id)
{
    new 
AuthID[35]
    
get_user_authid(id,AuthID,34)
 
    new 
vaultkey[64],vaultdata[256]
    
format(vaultkey,63,"%s-Mod",AuthID)
    
format(vaultdata,255,"%i#%i#",PlayerXP[id],PlayerLevel[id],PlayerClass[id])
    
nvault_get(g_vault,vaultkey,vaultdata,255)
 
    
replace_all(vaultdata255"#"" ")
 
    new 
playerxp[32], playerlevel[32], playerclass[32]
 
    
parse(vaultdataplayerxp31playerlevel31playerclass31)
 
    
PlayerXP[id] = str_to_num(playerxp)
    
PlayerLevel[id] = str_to_num(playerlevel)
    
PlayerClass[id] = str_to_num(playerclass)
 
    return 
PLUGIN_CONTINUE



Foxa 08-21-2020 09:59

Re: Help me with this little problem [xpsystem] ;-;
 
Oh for f.. sake please use the [php] or the [pawn] tag..

LaranjoBreks 08-21-2020 11:28

Re: Help me with this little problem [xpsystem] ;-;
 
Quote:

Originally Posted by Foxa (Post 2715016)
Oh for f.. sake please use the [php] or the [pawn] tag..

?

Foxa 08-21-2020 11:57

Re: Help me with this little problem [xpsystem] ;-;
 
Use the [php] or [pawn] around your code so its readable:

PHP Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "Author"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
// Add your code here...


Code:
#include <amxmodx> #include <amxmisc> #define PLUGIN "New Plug-In" #define VERSION "1.0" #define AUTHOR "Author" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         // Add your code here... }

LaranjoBreks 08-21-2020 12:19

Re: Help me with this little problem [xpsystem] ;-;
 
Quote:

Originally Posted by Foxa (Post 2715028)
Use the [php] or [pawn] around your code so its readable:

PHP Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "Author"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
// Add your code here...


Code:
#include <amxmodx> #include <amxmisc> #define PLUGIN "New Plug-In" #define VERSION "1.0" #define AUTHOR "Author" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         // Add your code here... }


oh sorry, i didn't remember that

LaranjoBreks 08-21-2020 12:22

Re: Help me with this little problem [xpsystem] ;-;
 
Quote:

Originally Posted by Foxa (Post 2715028)
Use the [php] or [pawn] around your code so its readable:

PHP Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "Author"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
// Add your code here...


Code:
#include <amxmodx> #include <amxmisc> #define PLUGIN "New Plug-In" #define VERSION "1.0" #define AUTHOR "Author" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         // Add your code here... }

i already edited my post


All times are GMT -4. The time now is 13:51.

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