Русское сообщество по скриптингу

[Help] Run time error 4

Scripting help for english speaking users. While not very active, you still have a chance to get help here.
Правила форума
We cannot maintain english version version of our forum rules, but shortly (it's simple) - Don't be a dick. If you really want to know our rules you should check appropriate thread.

[Help] Run time error 4

Сообщение VenomIvanof » 04 авг 2016, 00:59

Someone can help?

L 08/03/2016 - 18:13:02: [AMXX] Displaying debug trace (plugin "levelmod.amxx")
L 08/03/2016 - 18:13:02: [AMXX] Run time error 4: index out of bounds
L 08/03/2016 - 18:13:02: [AMXX] [0] levelmod.sma::Playerspawn (line 315)
L 08/03/2016 - 18:13:02: [AMXX] [1] levelmod.sma::Playerspawn (line 320)

Код: Выделить всё
#include <amxmodx>
#include <amxmisc>
#include < cstrike >
#include < fun >
#include < hamsandwich >
#include <fun>
#include <nvault>  
#include < csx > 
#include <dhudmessage>
#include <colorchat>


//Define:

#define PLUGIN "Advanced Level Mode for Maina City"
#define VERSION "1.0"
#define AUTHOR "Training Day"

#define MAXLEVELS 9 

#define VIP ADMIN_LEVEL_A

//Cvars

new PlayerXP[33],PlayerLevel[33]
new 
XP_Kill,XP_Knife,XP_Hs,XP_AWP 
new XP_save 
new XP_plant,XP_defuse,XP_he
new g_vault 
new advertise


//Levels

new const LEVELS[MAXLEVELS] = {


100,
500,
1000,
5000,
10000,
50000,
60000,
90000,
100000
}  

//Plugin_init

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
    
register_clcmd("say /xp" ,"PrintXp"
    
    
register_concmd("amx_givexp" ,"CmdGiveXp",ADMIN_RCON,"Give user EXP")
    
register_concmd("amx_takexp""CmdTakeXp",ADMIN_RCON,"TAK USER EXP")
    
register_concmd("amx_xp" ,"CmdFindXp" ,ADMIN_RCON,"EXP INFO")
    
    
//Ham
    
    
RegisterHamHam_Spawn"player""Playerspawn")
    
    
register_event"DeathMsg""DeathMsg""a" )
    
        
    
    
XP_Kill=register_cvar("xp_kill","10"
    
XP_Hs=register_cvar("xp_hs","15"
    
XP_AWP=register_cvar("xp_awp","20")
    
XP_Knife=register_cvar("xp_knife","30"
    
XP_plant=register_cvar("xp_plant","50")
    
XP_defuse=register_cvar("xp_defuse","50"
    
XP_save=register_cvar("xp_save" ,"1")   
    
XP_he=register_cvar("xp_he","40"
    
advertise=register_cvar("xp_advertise" ,"1"
    
    
    
g_vault=nvault_open("XpClasicMod"//nvault name
    
        
}

public 
client_putinserver(id) {
          
        if(
get_pcvar_num(XP_save)==1)  { 
            
LoadXp(id
            
    }
    
        
set_task(20.0,"ClientMsg",id)
        
        
    
}

public 
ReminderMsg()
{
    
set_task(15.0"ReminderMsg"0__"b")
}

    public 
client_disconnect(id) {
    
    if(
get_pcvar_num(XP_save)==1)  { 
                        
SaveXp(id)    
                
PlayerXP[id]=0      
                PlayerLevel
[id]=
                                 
    
}
}

 
public 
SaveXp(id)  

     
    new 
name[32]
    
get_user_name(id,name,31
    new 
vaultkey[64],vaultdata[256
 
    
format(vaultkey,63,"%s-XpClasic",name)  
    
format(vaultdata,255,"%i#%i#",PlayerXP[id],PlayerLevel[id]) 
    
    
nvault_set(g_vault,vaultkey,vaultdata)  
    return 
PLUGIN_CONTINUE 
}  

public 
LoadXp(id

    new 
name[32]
    
get_user_name(id,name,31
    new 
vaultkey[64],vaultdata[256
    
    
format(vaultkey,63,"%s-XpClasic",name
    
format(vaultdata,255,"%i#%i#",PlayerXP[id],PlayerLevel[id]) 
 
    
nvault_get(g_vault,vaultkey,vaultdata,255
    
replace_all(vaultdata255"#"" "
    new 
playerxp[32], playerlevel[32
    
parse(vaultdataplayerxp31playerlevel31
    
PlayerXP[id] = str_to_num(playerxp
    
PlayerLevel[id] = str_to_num(playerlevel
  
    
    return 
PLUGIN_CONTINUE 
}  


public 
ClientMsg(id) { 
    
    if(
get_pcvar_num(advertise) == 1) {
    
    
ColorChat(id,GREY,"^4[^3Maina City^4] ^3Maina City ^4Exp System"
    
ColorChat(id,GREY,"^4[^3Maina City^4] ^3Make Kills to earn ^4EXP")
    
ColorChat(id,GREY,"^4[^3Maina City^4] ^3With every ^4level^3you will get more ^4extra items")
             }
}



public 
PrintXp(id) {
    
 
ColorChat(idGREY,"You have ^4%i ^3exp and you are level ^4%i ",PlayerXP[id],PlayerLevel[id])
 
set_dhudmessage(2552552550.00.1426.012.0)
 
show_dhudmessage(id"You have ^4%i ^3exp and you are level ^4%i ",PlayerXP[id],PlayerLevel[id])

    
}

public 
CmdGiveXp(id) { 
    
    if( 
get_user_flagsid ) & ADMIN_RCON )
    {
        new 
PlayerToGive32 ], XP32 ]
        
read_argv1,PlayerToGive31 )
        
read_argv2XP31 )
        new 
Player cmd_targetidPlayerToGive)
        if( !
Player ) {
            return 
1
        
}
        
        
        new 
XPtoGive str_to_numXP )
        new 
name32 ], owner32 ]
        
get_user_nameidowner31 )
        
get_user_namePlayername31 )
        
ColorChat(0GREY,"Admin ^4%s ^3give exp to ^4%s ^4[^3%s exp^4]."owner,name,XP)
        
PlayerXPPlayer ] += XPtoGive
        SaveXp
id )
    }
    else 
    {
        
ColorChatidGREY"^4[^3Maina City^4] ^3You dont have ^4access ^3to this command" )
    }
    return 
0
    
    
    
}

public 
CmdTakeXp(id) { 
    
    if( 
get_user_flagsid ) & ADMIN_RCON )
    {
        new 
PlayerToTake32 ], XP32 ]
        
read_argv1PlayerToTake31 )
        
read_argv2XP31 )
        new 
Player cmd_targetidPlayerToTake)
        if( !
Player ) {
        
        return 
1
     
}
    
        new 
XPtoTake str_to_numXP )
        new 
name32 ], owner32 ]
        
get_user_nameidowner31 )
        
get_user_namePlayername31 )
        
ColorChat(0GREY,"Admin ^4%s ^3take exp from ^4%s ^4[^3%s exp^4].",owner,name,XP)
        
PlayerXPPlayer ] -= XPtoTake
        SaveXp
id )
    }

    else 
    {
        
ColorChatidGREY"You dont have access to this command." );
    }
    return 
0
    
    
    
}
    
    public 
CmdFindXp(id) { 
        
        if( 
get_user_flagsid ) & ADMIN_RCON)
    {
        new  
Arg132 ]
        
read_argv1Arg131 )
        new 
PlayertoFindcmd_targetidArg1)
        if( !
PlayertoFind ) {
        
    return 
1
    
}
    
    
    
        new  
Name32 ]
        
get_user_nameidName31 )
        
ColorChatidGREY"Player %s are level %i and %i XP."NamePlayerLevelPlayertoFind], PlayerXPPlayertoFind ] )
    }
        else 
    {
        
ColorChatidGREY"^4[^3Maina City^4] ^3You dont have ^4access ^3to this command" )
    }
        return 
0
        
        
        
    
}
    
    
    public 
DeathMsg(iWpnIndex) {
        new 
headshot=read_data(3
        new 
Victim=read_data(2
        new 
victim_name[32
        
get_user_nameVictimvictim_name31 
        new 
weaponHitPointattacker get_user_attackerVictimweaponHitPoint
        
        static 
sFlagssFlags get_user_flags(attacker);
        const 
XpVipHs 10;
        const 
XpVip 3;
        if(
headshot)  {
         
PlayerXP[attacker] += sFlags VIP XpVipHs get_pcvar_num(XP_Hs)    
         
ColorChat(attackerGREY,"You get  %i exp for killing with HeadShot Player %s.",get_pcvar_num(XP_Hs),victim_name)    
    
        }
        
        else {
        
        
        
PlayerXP[attacker ] += sFlags VIP XpVip get_pcvar_numXP_Kill 
        
ColorChat(attackerGREY,"You get  %i exp for killing Player:^4 %s. ",get_pcvar_num(XP_Kill),victim_name)
    }
        
        if(
weapon== CSW_KNIFE) {
                            
PlayerXP[attacker] += get_pcvar_num(XP_Knife)  
                            
ColorChat(attackerGREY,"You get  %i exp for killing Player:^4 %s ^3with knife.",get_pcvar_num(XP_Knife),victim_name)    
        
        }
        
        if(
weapon== CSW_AWP) {
          
PlayerXP[attacker] += get_pcvar_num(XP_AWP)     
          
ColorChat(attackerGREY,"You get %i exp for killing Player: ^4%s. ^3with ^4AWP",get_pcvar_num(XP_AWP),victim_name)        
        
        }
        
        if( 
iWpnIndex == CSW_HEGRENADE )
    {
                   
PlayerXP[attacker] += get_pcvar_num(XP_he)  
           
ColorChat(attackerGREY,"You get %i exp for killing Player: %s. with HE Grenade",get_pcvar_num(XP_he),victim_name)        
        
    }
        

    
    
}

public  
Playerspawnid )
{
    
        
        if( ( 
PlayerLevelid] < && ( PlayerXPid ] > LEVELSPlayerLevelid ] ] ) ) )
    
    {
        while( 
PlayerXPid ] > LEVELSPlayerLevelid] ] )
        {
            
PlayerLevelid] += 1
            
            
            ColorChat
(idGREY,"Congratz now you have^4 %i ^3exp and you are Level: ^4%i ",PlayerXP[id],PlayerLevel[id])
        }
    }
    
            
set_task5.0"Player_items"id )
                   
        }
    
    

public 
bomb_plantedplanter 


PlayerXP[planter] += get_pcvar_num(XP_plant
ColorChat(planterGREY,"You get %i exp for planting the ^4BOMB.",get_pcvar_num(XP_plant))    



public 
bomb_defuseddefuser 


PlayerXP[defuser] += get_pcvar_num(XP_defuse)  
ColorChat(defuserGREY,"You get ^4%i ^3exp for defusing the ^4BOMB.",get_pcvar_num(XP_defuse))    

}  
      
public 
Player_items(id) {

    if( 
PlayerLevelid ] == ) {
    
ColorChat(idGREY,"^4[^3Maina City^4]^3 You are level 1.")
ColorChat(idGREEN,"^4[^3Maina City^4]^3 You get 1 Flash.")
give_item(id"weapon_flashbang")
    
    }
    else if( 
PlayerLevelid ] == ) {
    
    
ColorChat(idRED,"^4[^3Maina City^4]^3 You are level 2")
    
ColorChat(idGREEN,"You get 1 Flash, 1 HE")
    
give_item(id"weapon_flashbang")
    
give_item(id"weapon_hegrenade")
    }
    
             
    else if( 
PlayerLevelid ] == ) {
    
    
ColorChat(idRED,"^4[^3Maina City^4]^3 You are level 3")
    
ColorChat(idGREEN,"You get Grenade pack")
    
give_item(id"weapon_flashbang")
    
give_item(id"weapon_hegrenade")
    
give_item(id"weapon_smokegrenade")
    
    }
    
    else if( 
PlayerLevelid ] == ) {
    
    
ColorChat(idRED,"^4[^3Maina City^4]^3 You are Level 4")
    
ColorChat(idGREEN,"You get 2 Flash, 1 HE, +5HP ")
    
give_item(id"weapon_flashbang")
    
set_user_health(idget_user_health(id) + 5);
    
give_item(id,"weapon_deagle")
    
cs_set_user_bpammo(idCSW_DEAGLE30)
    }
    

    
    else if( 
PlayerLevelid ] == ) {
    
    
ColorChat(idRED,"^4[^3Maina City^4]^3 You are Level 5")
    
ColorChat(idGREEN,"You get Deagle, 2 Flash, 1 HE, +5HP, +50AP")
    
give_item(id,"weapon_deagle")
    
cs_set_user_bpammo(idCSW_DEAGLE30)
    
set_user_health(idget_user_health(id) + 5);
    
set_user_armor(idget_user_armor(id) + 50);
    }
        
    else if( 
PlayerLevelid ] == 6) {
    
    
ColorChat(idRED,"^4[^3Maina City^4]^3 You are Level 6")
    
ColorChat(idGREEN,"You get Deagle, 2 Flash, 1 He, 1 Smoke, +10HP")
    
give_item(id,"weapon_deagle")
    
cs_set_user_bpammo(idCSW_DEAGLE30)
    
give_item(id"weapon_smokegrenade")
    
give_item(id"weapon_hegrenade")
    
give_item(id"weapon_flashbang")
    
set_user_health(idget_user_health(id) + 10);
    
    }
        
    else if( 
PlayerLevelid ] == ) {
    
    
ColorChat(idRED,"^4[^3Maina City^4]^3 You are Level 7")
    
ColorChat(idGREEN,"You get Deagle, 2Flash, 1HE, +10HP, +55AP + M4a1")
    
give_item(id,"weapon_deagle")
    
cs_set_user_bpammo(idCSW_DEAGLE30)
    
give_item(id,"weapon_m4a1")
    
cs_set_user_bpammo(idCSW_M4A190)
    
give_item(id"weapon_flashbang")
    
cs_set_user_bpammo(idCSW_FLASHBANG2)
    
give_item(id"weapon_hegrenade")
    
set_user_health(idget_user_health(id) + 10);
    
set_user_armor(idget_user_armor(id) + 55);
    
    
    }

    else if( 
PlayerLevelid ] == ) {
    
    if (
cs_get_user_team(id) == CS_TEAM_T ){    
    
ColorChat(idRED,"You are Level 8")
    
ColorChat(idGREEN,"You get Deagle, AK47, +10HP, +60AP")
    
strip_user_weapons(id);
    
give_item(id,"weapon_deagle")
    
cs_set_user_bpammo(idCSW_DEAGLE30)
    
give_item(id,"weapon_AK47")
    
cs_set_user_bpammo(idCSW_AK4790)
    
set_user_health(idget_user_health(id) + 10);
    
set_user_armor(idget_user_armor(id) + 60);
    }
    if (
cs_get_user_team(id) == CS_TEAM_CT) {
        
    
ColorChat(idRED,"^4[^3Maina City^4]^3 You are Level 8")
    
ColorChat(idGREEN,"You get Deagle, M4a1, +10HP, +60AP")
    
strip_user_weapons(id);
    
give_item(id,"weapon_deagle")
    
cs_set_user_bpammo(idCSW_DEAGLE30)
    
give_item(id"weapon_m4a1")
    
cs_set_user_bpammo(idCSW_M4A190)
    
set_user_health(idget_user_health(id) + 10);
    
set_user_armor(idget_user_armor(id) + 60);
    }
    
    }

    else if( 
PlayerLevelid ] == ) {
    
    if (
cs_get_user_team(id) == CS_TEAM_CT) {
    
    
ColorChat(idGREY,"^4[^3Maina City^4]^3 Your Level is^4 9")
    
ColorChat(idGREY,"Auto reward: Grenade Pack, AWP/M4A1+Deagle, +20HP, FULL Armor")
    
give_item(id,"weapon_deagle")
    
cs_set_user_bpammo(idCSW_DEAGLE30)
    
give_item(id"weapon_awp")
    
cs_set_user_bpammo(idCSW_AWP30)
    
give_item(id"weapon_m4a1")
    
cs_set_user_bpammo(idCSW_M4A190)
    
give_item(id"weapon_hegrenade")
    
cs_set_user_bpammo(idCSW_HEGRENADE1)
    
give_item(id"weapon_flashbang")
    
cs_set_user_bpammo(idCSW_FLASHBANG2)
    
give_item(id"weapon_smokegrenade")
    
cs_set_user_bpammo(idCSW_SMOKEGRENADE1)
    
set_user_health(idget_user_health(id) + 10)
    
set_user_armor(idget_user_armor(id) + 50);
    
    }        
    if (
cs_get_user_team(id) == CS_TEAM_T)  {
    
    
    
ColorChat(idGREY,"^4[^3Maina City^4]^3 Your Level is^4 9")
    
ColorChat(idGREY,"^4Auto reward: ^3Grenade Pack, ^4AWP/M4a1+Deagle, ^3+20HP, ^4FULL Armor")
    
give_item(id,"weapon_deagle")
    
cs_set_user_bpammo(idCSW_DEAGLE35)
    
give_item(id"weapon_awp")
    
cs_set_user_bpammo(idCSW_AWP30)
    
give_item(id"weapon_ak47")
    
cs_set_user_bpammo(idCSW_AK4790)
    
give_item(id"weapon_hegrenade")
    
cs_set_user_bpammo(idCSW_HEGRENADE1)
    
give_item(id"weapon_flashbang")
    
cs_set_user_bpammo(idCSW_FLASHBANG2)
    
set_user_health(idget_user_health(id) + 10);
    
set_user_armor(idget_user_armor(id) + 100);
    }
    
    
    
}

 
 
Аватара пользователя
VenomIvanof
 
Сообщения: 66
Зарегистрирован: 02 апр 2016, 13:26
Благодарил (а): 17 раз.
Поблагодарили: 1 раз.
Языки программирования: Counter-Strike 1.6

Re: [Help] Run time error 4

Сообщение Pafos » 04 авг 2016, 13:05

Код: Выделить всё
public  Playerspawnid )
{
    if(!
is_user_connected(id)) return;
    
// code...
 
Аватара пользователя
Pafos
 
Сообщения: 574
Зарегистрирован: 07 апр 2014, 18:03
Откуда: pfnClientConnect
Забанен
Благодарил (а): 129 раз.
Поблагодарили: 97 раз.
Опыт программирования: Больше трех лет
Языки программирования: Pawn

Re: [Help] Run time error 4

Сообщение VenomIvanof » 05 авг 2016, 12:11

now i have second error :(

Код: Выделить всё
L 08/05/2016 01:50:14: [AMXXRun time error 4index out of bounds 
L 08
/05/2016 01:50:14: [AMXX]    [0colorchat.inc::ColorChat (line 74)
L 08/05/2016 01:50:14: [AMXX]    [1Untitled.sma::ClientMsg (line 153
Аватара пользователя
VenomIvanof
 
Сообщения: 66
Зарегистрирован: 02 апр 2016, 13:26
Благодарил (а): 17 раз.
Поблагодарили: 1 раз.
Языки программирования: Counter-Strike 1.6

Re: [Help] Run time error 4

Сообщение RevCrew » 07 авг 2016, 21:53

Код: Выделить всё
public ClientMsg(id) { 
    
    if(
get_pcvar_num(advertise) == 1) {
    
    
ColorChat(id,GREY,"^4[^3Maina City^4] ^3Maina City ^4Exp System"
    
ColorChat(id,GREY,"^4[^3Maina City^4] ^3Make Kills to earn ^4EXP")
    
ColorChat(id,GREY,"^4[^3Maina City^4] ^3With every ^4level^3you will get more ^4extra items")
             }

>>

Код: Выделить всё
public ClientMsg(id) { 
    
    if(
get_pcvar_num(advertise) == && is_user_connected(id)) {
    
    
ColorChat(id,GREY,"^4[^3Maina City^4] ^3Maina City ^4Exp System"
    
ColorChat(id,GREY,"^4[^3Maina City^4] ^3Make Kills to earn ^4EXP")
    
ColorChat(id,GREY,"^4[^3Maina City^4] ^3With every ^4level^3you will get more ^4extra items")
             }
}
 
Skype revcrew77
https://vk.com/cssuite
Аватара пользователя
RevCrew
Скриптер
 
Сообщения: 1354
Зарегистрирован: 15 июл 2013, 20:45
Благодарил (а): 240 раз.
Поблагодарили: 276 раз.
Языки программирования: Unkown


Вернуться в Scripting

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 1