AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Error when setting gravity, speed and life (https://forums.alliedmods.net/showthread.php?t=155551)

AlgoChikitito 04-23-2011 19:04

Error when setting gravity, speed and life
 
The problem is that the Start Round, Life Is in 100, this default rate and severity is also default.

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <nvault>
#include <fun>
#include <cstrike>
#include <hamsandwich>
#include <fakemeta_util>

#define MAXCLASSES 7

// Exp Classes
new LCiudanado 0
new LSoldado 200
new LEspia 1000
new LArmas_Pesadas 2800
new LFuerzas_Especiales 6800
new LSniper 15000
new LSuper_Soldado 25000

// Clases
new Ciudanado[33]
new 
Soldado[33]
new 
Espia[33]
new 
Armas_Pesadas[33]
new 
Fuerzas_Especiales[33]
new 
Sniper[33]
new 
Super_Soldado[33]

new const 
CLASSES[MAXCLASSES][] = {
    
"Ciudanado",
    
"Soldado",
    
"Espia",
    
"Armas Pesadas",
    
"Fuerzas_Especiales",
    
"Sniper",
    
"Super_Soldado"
}

new 
PlayerXP[33],PlayerClass[33]
new 
XP_Kill,SaveXP,g_vault

public plugin_init()
{
    
register_plugin("XpMod""1.0""Fxfighter")
    
RegisterHam(Ham_Killed"player""fw_PlayerKilled")
    
RegisterHam(Ham_Spawn"player""fw_playerspawn"1)
 
    
SaveXP=register_cvar("SaveXP","1")
    
XP_Kill=register_cvar("XP_per_kill""20")
    
//XP_Hs=register_cvar("XP_hs_bonus","10")
    //XP_Knife=register_cvar("XP_knife_bonus","20")
    
g_vault=nvault_open("experiencia_final1")
 
    
register_clcmd("say /class""ChangeClass")
    
register_clcmd("say_team /class""ChangeClass")
    
register_clcmd("say /clase""ChangeClass")
    
register_clcmd("say_team /clase""ChangeClass")
    
register_clcmd("say /xp""VerXp")
    
register_clcmd("say_team /xp""VerXp")
    
    
register_concmd("amx_xp""cmd_givexp"ADMIN_RCON"<target> <xp count> - Nombre del jugador y cantidad de experiencia")
}

public 
cmd_givexp(id)
{
    new 
userflagsuserflags get_user_flags(id) & ADMIN_RCON
    
    
if(!userflags)
    {
        
ChatColor(id"No tienes acceso")
        return 
PLUGIN_HANDLED
    
}
    
    
// Retrieve arguments
    
new arg[32], szxp[8], playerxp
    read_argv
(1argcharsmax(arg))
    
read_argv(2szxpcharsmax(szxp))
    
    
player cmd_target(idargCMDTARGET_ALLOW_SELF)
    
xp str_to_num(szxp)
    
    
// Invalid target
    
if (!player || (xp 1)) 
    {
        
console_print(id"Nombre no valido o la cantidad de xp es menor a 1")
        return 
PLUGIN_HANDLED
    
}
    
    
PlayerXP[player] += xp
    
    
if (id != player)
        
client_print(playerprint_chat"XP: %d"xp)
    
    new 
uName[33]; get_user_name(playeruNamecharsmax(uName))
    
    
console_print(id"Le sumaste %d de XP a %s"xpuName)
    
    return 
PLUGIN_HANDLED
}

public 
fw_PlayerKilled(victimattackershouldgib)
{
    new 
clipammo get_user_weapon(attacker,clip,ammo)
    
    new 
OnlyPoliceOnlyPolice get_user_team(attacker)
    
    if(
is_user_alive(attacker) && OnlyPolice == 2)
        
PlayerXP[attacker] += get_pcvar_num(XP_Kill)
}

public 
fw_playerspawn(id)
{
    if(
Soldado[id])
    {
        
fm_strip_user_weapons(id)
        
fm_give_item(id"weapon_knife")
        
fm_give_item(id"weapon_usp")
        
fm_give_item(id"weapon_m4a1")
        
fm_give_item(id"weapon_hegrenade")
        
fm_give_item(id"weapon_flashbang")
        
fm_give_item(id"weapon_smokegrenade")
        
give_item(id,"ammo_556nato"// Balas m4a1
        
give_item(id,"ammo_45acp"// Balas Usp
        
set_user_health(id110)
        
set_user_armor(id0)
        
set_user_maxspeedid get_user_maxspeedid ) + 0.0 )  
        
cs_set_user_model(id"lvg-Soldado")
    }
    
    else if(
Espia[id])
    {
        
fm_strip_user_weapons(id)
        
fm_give_item(id"weapon_knife")
        
fm_give_item(id"weapon_usp")
        
fm_give_item(id"weapon_m4a1")
        
fm_give_item(id"weapon_hegrenade")
        
fm_give_item(id"weapon_flashbang")
        
fm_give_item(id"weapon_smokegrenade")
        
give_item(id,"ammo_556nato"// Balas m4a1
        
give_item(id,"ammo_45acp"// Balas Usp
        
set_user_health(id120)
        
set_user_armor(id10)
        
set_user_gravity(id0.9)
        
set_user_maxspeedid get_user_maxspeedid ) + 0.0 )
        
cs_set_user_model(id"lvg-Espia")
    }
    
    else if(
Armas_Pesadas[id])
    {
        
fm_strip_user_weapons(id)
        
fm_give_item(id"weapon_knife")
        
fm_give_item(id"weapon_deagle")
        
fm_give_item(id"weapon_m249")
        
fm_give_item(id"weapon_hegrenade")
        
fm_give_item(id"weapon_flashbang")
        
fm_give_item(id"weapon_smokegrenade")
        
give_item(id,"ammo_50ae"// Balas Deagle
        
give_item(id,"ammo_556nato"// Balas MAchineGun
        
set_user_health(id130)
        
set_user_armor(id30)
    
set_user_gravity(id0.8)
        
set_user_maxspeedid get_user_maxspeedid ) + 10.0 
        
cs_set_user_model(id"lvg-ArmasPesadas")
    }
    
    else if(
Fuerzas_Especiales[id])
    {
        
fm_strip_user_weapons(id)
        
fm_give_item(id"weapon_knife")
        
fm_give_item(id"weapon_usp")
        
fm_give_item(id"weapon_deagle")
        
fm_give_item(id"weapon_m4a1")
        
fm_give_item(id"weapon_ak47")
        
fm_give_item(id"weapon_hegrenade")
        
fm_give_item(id"weapon_flashbang")
        
fm_give_item(id"weapon_flashbang")
        
fm_give_item(id"weapon_smokegrenade")
        
give_item(id,"ammo_556nato"// Balas M4a1
        
give_item(id,"ammo_45acp"// Balas Usp
        
give_item(id,"ammo_50ae"// Balas Dealge
        
give_item(id,"ammo_762nato"// Balas Ak47
        
set_user_health(id150)
        
set_user_armor(id50)
            
set_user_gravity(id0.7)
        
set_user_maxspeedid get_user_maxspeedid ) + 25.0 )
        
cs_set_user_model(id"lvg-FuerzasEspeciales")
    }
    
    else if(
Sniper[id])
    {
        
fm_strip_user_weapons(id)
        
fm_give_item(id"weapon_knife")
        
fm_give_item(id"weapon_usp")
        
fm_give_item(id"weapon_awp")
        
fm_give_item(id"weapon_scout")
        
fm_give_item(id"weapon_g3sg1")
        
fm_give_item(id"weapon_hegrenade")
        
fm_give_item(id"weapon_flashbang")
        
fm_give_item(id"weapon_flashbang")
        
fm_give_item(id"weapon_smokegrenade")
        
give_item(id,"ammo_45acp"// Balas Usp
        
give_item(id,"ammo_338magnum"// Balas Awp
        
give_item(id,"ammo_762nato"// Balas Scout
        
give_item(id,"ammo_762nato"// Balas G3sg1
        
set_user_health(id200)
        
set_user_armor(id75)
        
set_user_gravity(id0.1)
        
cs_set_user_model(id"lvg-Sniper")
    }
    
    else if(
Super_Soldado[id])
    {
        
fm_strip_user_weapons(id)
        
fm_give_item(id"weapon_knife")
        
fm_give_item(id"weapon_usp")
        
fm_give_item(id"weapon_deagle")
        
fm_give_item(id"weapon_m4a1")
        
fm_give_item(id"weapon_ak47")
        
fm_give_item(id"weapon_m249")
        
fm_give_item(id"weapon_m3")
        
fm_give_item(id"weapon_hegrenade")
        
fm_give_item(id"weapon_flashbang")
        
fm_give_item(id"weapon_flashbang")
        
fm_give_item(id"weapon_smokegrenade")
        
give_item(id,"ammo_556nato"// Balas M4a1
        
give_item(id,"ammo_45acp"// Balas Usp
        
give_item(id,"ammo_50ae"// Balas Dealge
        
give_item(id,"ammo_762nato"// Balas Ak47
        
give_item(id"ammo_buckshot"// Balas Escopeta
        
fm_set_user_healthid300 )
        
fm_set_user_armorid100 )
        
fm_set_user_maxspeed(id300.0)
        
cs_set_user_model(id"lvg-supersoldado")
    }
    
    else
    {
        
fm_strip_user_weapons(id)
        
fm_give_item(id"weapon_knife")
        
fm_give_item(id"weapon_usp")
        
fm_give_item(id"weapon_m4a1")
        
fm_give_item(id"weapon_hegrenade")
        
fm_give_item(id"weapon_flashbang")
        
fm_give_item(id"weapon_smokegrenade")
        
give_item(id,"ammo_556nato"// Balas M4a1
        
give_item(id,"ammo_45acp"// Balas Usp
        
set_user_health(id100)
        
set_user_armor(id0)
        
set_user_maxspeedid get_user_maxspeedid ) + 0.0 )
        
cs_set_user_model(id"lvg-ciudadano")
    }
}

public 
VerXp(id)
{
    
ChatColor(id,"!g[ZPLVG] !yXp: !g%d",PlayerXP[id])
    
ChatColor(id,"!g[ZPLVG] !yXp: !g%d",PlayerXP[id])
    
ChatColor(id,"!g[ZPLVG] !yXp: !g%d",PlayerXP[id])
    
ChatColor(id,"!g[ZPLVG] !yXp: !g%d",PlayerXP[id])
}
public 
ChangeClass(id)
{
    new 
menu menu_create("Class Menu" "Class_Handle");
    
    if(
PlayerXP[id] >= LCiudanado)
        
menu_additem(menu ,"\wCiudadano | \rClase Libre""0" 0);
    else
        
menu_additem(menu ,"\dCiudadano | \rClase Libre""0" 0);
    
    if(
PlayerXP[id] >= LSoldado)
        
menu_additem(menu ,"\wSoldado | \r200 Xp""1" 0);
    else
        
menu_additem(menu ,"\dSoldado | \r200 Xp""1" 0);
    
    if(
PlayerXP[id] >= LEspia)
        
menu_additem(menu ,"\wEspia | \r1000 Xp""2" 0);
    else
        
menu_additem(menu ,"\dEspia | \r1000 Xp""2" 0);
    
    if(
PlayerXP[id] >= LArmas_Pesadas)
        
menu_additem(menu ,"\wArmas Pesadas | \r2800 Xp""3" 0);
    else
        
menu_additem(menu ,"\dArmas Pesadas | \r2800  Xp""3" 0);
        
    if(
PlayerXP[id] >= LFuerzas_Especiales)    
        
menu_additem(menu ,"\wFuerzas Especiales | \r6800 Xp""4" 0);
    else
        
menu_additem(menu ,"\dFuerzas Especiales | \r6800 Xp""4" 0);
        
    if(
PlayerXP[id] >= LSniper)    
        
menu_additem(menu ,"\wSniper | \r15000 Xp""5" 0);
    else
        
menu_additem(menu ,"\dSniper| \r15000 Xp""5" 0);
    
    if(
PlayerXP[id] >= LSuper_Soldado)
        
menu_additem(menu ,"\wSuper Soldado | \r25000 Xp""6" 0);
    else
        
menu_additem(menu ,"\dSuper Soldado | \r25000 Xp""6" 0);
    
    
menu_setprop(menu MPROP_EXIT MEXIT_ALL);
    
    
menu_display(id menu 0);
    
    return 
PLUGIN_CONTINUE;
}
public 
Class_Handle(id menu item)
{
    if(
item == MENU_EXIT)
    {
 
        
menu_destroy(menu);
 
    }
 
    new 
szCommand[6] , szName[64];
    new 
access callback;
 
    
menu_item_getinfo(menu item access szCommand szName 63 callback);
 
    new 
str_to_num(szCommand)
    
    new 
ClassXP
    
    
for(new _i i;_i;_i++)
    {
        switch(
_i)
    {
        case 
1ClassXP 0
        
case 2ClassXP 200
        
case 3ClassXP 1000
        
case 4ClassXP 2800
        
case 5ClassXP 6800
        
case 6ClassXP 15000
        
case 7ClassXP 25000
    
}
    
    if(
PlayerXP[id] >= ClassXP)
    {
        
PlayerClass[id] = i
        ChatColor
(id,"!g[ZPLVG] !yEn La Proxima Ronda Tu Clase Sera !g%s",CLASSES[i])
        return 
PLUGIN_CONTINUE
    
}
    
    else
    {
        
ChatColor(id,"!g[ZPLG] !yNecesitas Tener !team%d !y de XP para elegir esta clase"ClassXP)
        
ChangeClass(id)
        return 
PLUGIN_HANDLED
    
}
    }
        
        
   
    
    
menu_destroy(menu);
    
    switch (
str_to_num(szCommand))
     {    
    case 
0// Ciudadano
    
{
        
Ciudanado[id] = 1
        Soldado
[id] = 0
        Espia
[id] = 0
        Armas_Pesadas
[id] = 0
        Fuerzas_Especiales
[id] = 0
        Sniper
[id] = 0
        Super_Soldado
[id] = 0
        
    
}
    case 
1// Soldado    
    
{
        
Ciudanado[id] = 0
        Soldado
[id] = 1
        Espia
[id] = 0
        Armas_Pesadas
[id] = 0
        Fuerzas_Especiales
[id] = 0
        Sniper
[id] = 0
        Super_Soldado
[id] = 0
        
    
}    
    case 
2// Espia
    
{
        
Ciudanado[id] = 0
        Soldado
[id] = 0
        Espia
[id] = 1
        Armas_Pesadas
[id] = 0
        Fuerzas_Especiales
[id] = 0
        Sniper
[id] = 0
        Super_Soldado
[id] = 0
        
    
}
    case 
3// Armas Pesadas    
    
{
        
Ciudanado[id] = 0
        Soldado
[id] = 0
        Espia
[id] = 0
        Armas_Pesadas
[id] = 1
        Fuerzas_Especiales
[id] = 0
        Sniper
[id] = 0
        Super_Soldado
[id] = 0
        
    
}
    case 
4// Fuerzas Especiales    
    
{
        
Ciudanado[id] = 0
        Soldado
[id] = 0
        Espia
[id] = 0
        Armas_Pesadas
[id] = 0
        Fuerzas_Especiales
[id] = 1
        Sniper
[id] = 0
        Super_Soldado
[id] = 0
        
    
}
    case 
5// Sniper    
    
{
        
Ciudanado[id] = 0
        Soldado
[id] = 0
        Espia
[id] = 0
        Armas_Pesadas
[id] = 0
        Fuerzas_Especiales
[id] = 0
        Sniper
[id] = 1
        Super_Soldado
[id] = 0
        
    
}
    case 
6// Soldado    
    
{
        
Ciudanado[id] = 0
        Soldado
[id] = 0
        Espia
[id] = 0
        Armas_Pesadas
[id] = 0
        Fuerzas_Especiales
[id] = 0
        Sniper
[id] = 0
        Super_Soldado
[id] = 1
        
    
}
     }
        
    return 
PLUGIN_HANDLED
}
    
public 
client_connect(id)
{
    if(
get_pcvar_num(SaveXP) == 1)
    {
 
        
LoadData(id)
    }
    
    
Ciudanado[id] = 0
    Soldado
[id] = 0
    Espia
[id] = 0
    Armas_Pesadas
[id] = 0
    Fuerzas_Especiales
[id] = 0
    Sniper
[id] = 0
    Super_Soldado
[id] = 0
    
}
public 
client_disconnect(id)
{
    if(
get_pcvar_num(SaveXP) == 1)
    {
 
        
SaveData(id)
    }
    
PlayerXP[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#",PlayerXP[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#",PlayerXP[id])
    
nvault_get(g_vault,vaultkey,vaultdata,255)
 
    
replace_all(vaultdata255"#"" ")
 
    new 
playerxp[32]
 
    
parse(vaultdataplayerxpcharsmax(playerxp))
 
    
PlayerXP[id] = str_to_num(playerxp)
 
    return 
PLUGIN_CONTINUE
}

public 
plugin_precache() 

        
precache_model("models/player/lvg-ciudadano/lvg-ciudadano.mdl"
        
precache_model("models/player/lvg-soldado/lvg-soldado.mdl"
        
precache_model("models/player/lvg-espia/lvg-espia.mdl")
        
precache_model("models/player/lvg-armaspesadas/lvg-armaspesadas.mdl"
        
precache_model("models/player/lvg-fuerzasespeciales/lvg-fuerzasespeciales.mdl"
        
precache_model("models/player/lvg-sniper/lvg-sniper.mdl")
        
precache_model("models/player/lvg-supersoldado/lvg-supersoldado.mdl")        
}

stock ChatColor(const id, const input[], any:...)
{
    new 
count 1players[32]
    static 
msg[191]
    
vformat(msg190input3)
    
    
replace_all(msg190"!g""^4"// Green Color
    
replace_all(msg190"!y""^1"// Default Color
    
replace_all(msg190"!team""^3"// Team Color
    
replace_all(msg190"!team2""^0"// Team2 Color
    
    
if (idplayers[0] = id; else get_players(playerscount"ch")
    {
        for (new 
0counti++)
        {
            if (
is_user_connected(players[i]))
            {
                
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _players[i])
                
write_byte(players[i]);
                
write_string(msg);
                
message_end();
            }
        }
    }


What is the problem?
Thanks
sorry for my bad English

ProIcons 04-23-2011 19:20

Re: Error when setting gravity, speed and life
 
rewrite more clearly your problem, use

http://translate.google.com
or
http://babelfish.yahoo.com if you can't

AlgoChikitito 04-23-2011 19:31

Re: Error when setting gravity, speed and life
 
this is the problem.

I give 300 life - only give 100
I give 0.5 gravity - only give 1.0
I give him 300 speed - only give 250 speed


I use the translator

ProIcons 04-23-2011 19:40

Re: Error when setting gravity, speed and life
 
if(Soldado[id])

have you tried to add a debug message to see if your code reach to the point you want? example

PHP Code:

 if(Soldado[id]) 
    { 
        
fm_strip_user_weapons(id
        
fm_give_item(id"weapon_knife"
        
fm_give_item(id"weapon_usp"
        
fm_give_item(id"weapon_m4a1"
        
fm_give_item(id"weapon_hegrenade"
        
fm_give_item(id"weapon_flashbang"
        
fm_give_item(id"weapon_smokegrenade"
        
give_item(id,"ammo_556nato"// Balas m4a1 
        
give_item(id,"ammo_45acp"// Balas Usp 
        
set_user_health(id110
        
set_user_armor(id0
        
set_user_maxspeedid get_user_maxspeedid ) + 0.0 )   
        
cs_set_user_model(id"lvg-Soldado"
    } 

to

PHP Code:

 if(Soldado[id]) 
    { 
        
fm_strip_user_weapons(id
        
fm_give_item(id"weapon_knife"
        
fm_give_item(id"weapon_usp"
        
fm_give_item(id"weapon_m4a1"
        
fm_give_item(id"weapon_hegrenade"
        
fm_give_item(id"weapon_flashbang"
        
fm_give_item(id"weapon_smokegrenade"
        
give_item(id,"ammo_556nato"// Balas m4a1 
        
give_item(id,"ammo_45acp"// Balas Usp 
        
server_print("[XpMOD] Code Reached");
        
set_user_health(id110
        
set_user_armor(id0
        
set_user_maxspeedid get_user_maxspeedid ) + 0.0 )   
        
cs_set_user_model(id"lvg-Soldado"
    } 


AlgoChikitito 04-23-2011 20:02

Re: Error when setting gravity, speed and life
 
the message is not visible

SonicSonedit 04-23-2011 23:34

Re: Error when setting gravity, speed and life
 
AlgoChikitito
Check if some other plugin resets values to default.

AlgoChikitito 04-24-2011 13:02

Re: Error when setting gravity, speed and life
 
I did not understand what you meant

AlgoChikitito 04-24-2011 14:22

Re: Error when setting gravity, speed and life
 
Quote:

Originally Posted by ProIcons (Post 1456335)
if(Soldado[id])

have you tried to add a debug message to see if your code reach to the point you want? example

PHP Code:

 if(Soldado[id]) 
    { 
        
fm_strip_user_weapons(id
        
fm_give_item(id"weapon_knife"
        
fm_give_item(id"weapon_usp"
        
fm_give_item(id"weapon_m4a1"
        
fm_give_item(id"weapon_hegrenade"
        
fm_give_item(id"weapon_flashbang"
        
fm_give_item(id"weapon_smokegrenade"
        
give_item(id,"ammo_556nato"// Balas m4a1 
        
give_item(id,"ammo_45acp"// Balas Usp 
        
set_user_health(id110
        
set_user_armor(id0
        
set_user_maxspeedid get_user_maxspeedid ) + 0.0 )   
        
cs_set_user_model(id"lvg-Soldado"
    } 

to

PHP Code:

 if(Soldado[id]) 
    { 
        
fm_strip_user_weapons(id
        
fm_give_item(id"weapon_knife"
        
fm_give_item(id"weapon_usp"
        
fm_give_item(id"weapon_m4a1"
        
fm_give_item(id"weapon_hegrenade"
        
fm_give_item(id"weapon_flashbang"
        
fm_give_item(id"weapon_smokegrenade"
        
give_item(id,"ammo_556nato"// Balas m4a1 
        
give_item(id,"ammo_45acp"// Balas Usp 
        
server_print("[XpMOD] Code Reached");
        
set_user_health(id110
        
set_user_armor(id0
        
set_user_maxspeedid get_user_maxspeedid ) + 0.0 )   
        
cs_set_user_model(id"lvg-Soldado"
    } 


Sorry if the message is visible

ProIcons 04-27-2011 09:34

Re: Error when setting gravity, speed and life
 
If the message is visible means the code worked correctly either
that you have an error on your commands
even though i couldn't found it...

In the part i puted the "debug" message it must give to the user

"knife"
"usp"
"m4a1"
"grenades"
"ammos"
110 lifes
0 armor and normal maxpeed with model LVg_solado
if you the debug message appear and you don't have any of these...

try to make them:

Code:
 if(Soldado[id])       {           strip_user_weapons(id)           give_item(id, "weapon_knife")           give_item(id, "weapon_usp")           give_item(id, "weapon_m4a1")           give_item(id, "weapon_hegrenade")           give_item(id, "weapon_flashbang")           give_item(id, "weapon_smokegrenade")           give_item(id,"ammo_556nato") // Balas m4a1           give_item(id,"ammo_45acp") // Balas Usp           server_print("[XpMOD] Code Reached");         set_user_health(id, 110)           cs_set_user_armor(id, 0)           set_user_maxspeed( id , get_user_maxspeed( id ) + 0.0 )             cs_set_user_model(id, "lvg-Soldado")       }


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

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