Raised This Month: $ Target: $400
 0% 

Problem wyth respawn plugin


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 12-09-2014 , 08:37   Problem wyth respawn plugin
Reply With Quote #1

Can someone please help me wyth this error:
PHP Code:
[FUNInvalid player 20 (not in-game)
[
AMXXDisplaying debug trace (plugin "bio_hs.amxx")
[
AMXXRun time error 10native error (native "spawn")
[
AMXX]    [0bio_hs.sma::actual_revive (line 255)
[
FUNInvalid player 20 (not in-game)
[
AMXXDisplaying debug trace (plugin "bio_hs.amxx")
[
AMXXRun time error 10native error (native "spawn")
[
AMXX]    [0bio_hs.sma::actual_revive (line 255
This is respawn plugin:

PHP Code:
 #include <amxmodx>
 #include <amxmisc>
 #include <engine>
 #include <fun>
 #include <biohazard>

 #define PLUGNAME        "Halo Style Respawning"
 #define AUTHOR            "Emp`"
 #define VERSION        "1.31"

 #define    MAX_SPAWNS    60
 #define    MAX_SPEAK    10

 
new Float:HSRtime[33]                //countdown for the users
 
new SOrigin[33][3];

 new 
Float:g_SpawnVecs[MAX_SPAWNS][3];
 new 
Float:g_SpawnAngles[MAX_SPAWNS][3];
 new 
Float:g_SpawnVAngles[MAX_SPAWNS][3];
 new 
g_TotalSpawns;
 
 
//for pcvars
 
new sv_HSRsv_HSRspawnssv_HSRtimesv_HSRmaxtime
 
public plugin_init()
 {

    
register_plugin(PLUGNAMEVERSIONAUTHOR)

    
sv_HSR register_cvar("sv_HSR""1")
    
sv_HSRspawns register_cvar("sv_HSRspawns""0")
    
sv_HSRtime register_cvar("sv_HSRtime""1.0")
    
sv_HSRmaxtime register_cvar("sv_HSRmaxtime""10.0")

    
register_event("DeathMsg","DeathEvent","a")

    
readSpawns()
    
set_msg_block(get_user_msgid("ClCorpse"), BLOCK_SET);
 }

 
readSpawns()
 {    
    new 
Map[32], config[32],  MapFile[64];
    
    
get_mapname(Map31)
    
get_configsdir(config31 )
    
format(MapFile63"%s\csdm\%s.spawns.cfg"configMap);
    
g_TotalSpawns 0;
    
    if (
file_exists(MapFile)) 
    {
        new 
Data[124], len;
            new 
line 0;
            new 
pos[12][8];
            
        while(
g_TotalSpawns MAX_SPAWNS && (line read_file(MapFile line Data 123 len) ) != 
        {
            if (
strlen(Data)<|| Data[0] == '[')
                continue;

            
parse(Datapos[1], 7pos[2], 7pos[3], 7pos[4], 7pos[5], 7pos[6], 7pos[7], 7pos[8], 7pos[9], 7pos[10], 7);
            
            
// Origin
            
g_SpawnVecs[g_TotalSpawns][0] = str_to_float(pos[1]);
            
g_SpawnVecs[g_TotalSpawns][1] = str_to_float(pos[2]);
            
g_SpawnVecs[g_TotalSpawns][2] = str_to_float(pos[3]);
            
            
//Angles
            
g_SpawnAngles[g_TotalSpawns][0] = str_to_float(pos[4]);
            
g_SpawnAngles[g_TotalSpawns][1] = str_to_float(pos[5]);
            
g_SpawnAngles[g_TotalSpawns][2] = str_to_float(pos[6]);
            
            
//v-Angles
            
g_SpawnVAngles[g_TotalSpawns][0] = str_to_float(pos[7]);
            
g_SpawnVAngles[g_TotalSpawns][1] = str_to_float(pos[8]);
            
g_SpawnVAngles[g_TotalSpawns][2] = str_to_float(pos[9]);
            
            
//Team - ignore
            
            
g_TotalSpawns++;
        }
        
        
log_amx("Loaded %d spawn points for map %s."g_TotalSpawnsMap)
    } else {
        
log_amx("No spawn points file found (%s)"MapFile)
    }
    
    return 
1;
 }
 
 public 
spawn_Preset(id)
 {
    if (
g_TotalSpawns 2)
        return 
PLUGIN_CONTINUE
    
    
new list[MAX_SPAWNS];
    new 
num 0
    new final = -
1
    new 
total=0
    new 
players[32], n0;
    new 
Float:loc[32][3], locnum
    
    get_players
(playersnum)
    for (new 
i=0i<numi++)
    {
        if (
is_user_alive(players[i]) && players[i] != id)
        {
            
entity_get_vector(players[i], EV_VEC_originloc[locnum])
            
locnum++
        }
    }
    
    
num 0
    
while (num <= g_TotalSpawns)
    {
        if (
num == g_TotalSpawns)
            break;

        
random_num(0g_TotalSpawns-1);
        
        if (!list[
n])
        {
            list[
n] = 1;
            
num++;
        } 
        else 
        {
            
total++;
            if (
total 100
                break;
            continue;   
        }

        new 
trace  trace_hull(g_SpawnVecs[n],1);
        if (
trace)
            continue;
        
        if (
locnum 1)
        {
            final = 
n
            
break
        }
        
        final = 
n
        
for (0locnumx++)
        {
            new 
Float:distance get_distance_f(g_SpawnVecs[n], loc[x]);
            if (
distance 250.0)
            {
                
//invalidate
                
final = -1;
                break;
            }
        }
        
        if (final != -
1)
            break
    }
    
    if (final != -
1)
    {
        
entity_set_origin(idg_SpawnVecs[final]);
        
entity_set_int(idEV_INT_fixangle1);
        
entity_set_vector(idEV_VEC_anglesg_SpawnAngles[final]);
        
entity_set_vector(idEV_VEC_v_angleg_SpawnVAngles[final]);
        
entity_set_int(idEV_INT_fixangle1);
        
        return 
PLUGIN_HANDLED
    
}

    return 
PLUGIN_CONTINUE
 
}
 public 
DeathEvent()
 {
    new 
attacker read_data(1)
    new 
id read_data(2)

    if(
get_pcvar_num(sv_HSR)<1) return PLUGIN_CONTINUE
    
if(1>get_user_team(id)>2) return PLUGIN_CONTINUE

    
switch(get_pcvar_num(sv_HSR))
    {
        case 
2:{
            if(
is_user_connected(attacker)){
                if(
get_user_team(id)==get_user_team(attacker) || id==attacker){
                    
HSRtime[attacker] += get_pcvar_num(sv_HSRtime)
                    if(
HSRtime[attacker] > get_pcvar_num(sv_HSRmaxtime))
                        
HSRtime[attacker] = get_pcvar_float(sv_HSRmaxtime)
                }
            }
        }
        case 
1:{
            if(
is_user_alive(attacker)){
                
HSRtime[attacker] -= get_pcvar_num(sv_HSRtime)
                if(
HSRtime[attacker]<1.0)
                    
HSRtime[attacker] = 1.0
            
}

            
HSRtime[id] += get_pcvar_num(sv_HSRtime)
            if(
HSRtime[id] > get_pcvar_num(sv_HSRmaxtime))
                
HSRtime[id] = get_pcvar_float(sv_HSRmaxtime)
        }
        default: return 
PLUGIN_CONTINUE
    
}

    new 
time floatround(HSRtime[id]) + 1

    
new parm[2]
    
parm[0] = id
    parm
[1] = time

    set_task
(0.1,"check_respawn",0,parm,2)

    return 
PLUGIN_CONTINUE
 
}
 public 
check_respawn(parm[])
 {
    new 
id parm[0]
    
parm[1]--

    if(
is_user_alive(id) || !is_user_zombie(id) )
        return

    if(
parm[1]==0){
        
respawn(id)
    }
    else{
        if(
parm[1]<MAX_SPEAK){
            new 
speak[30]
            
num_to_word(parm[1], speak29)
            
client_cmd(id,"spk ^"fvox/%s^"",speak
        }
        
client_print(idprint_center"You will respawn in %d seconds."parm[1])
        
set_task(1.0,"check_respawn",0,parm,2)
    }
 }
 public 
respawn(id)
 {
    if( 
is_user_alive(id) ||  !is_user_connected(id)) return -1

    
if(is_user_zombie(id) ) {
        new 
parm[2]
        
parm[0] = id
        parm
[1] = 0
        set_task
0.5"actual_revive"1parm2)
        
parm[1] = 1
        set_task
0.7"actual_revive"1parm2)
        return 
1
    
}
    return 
0
 
}
 public 
actual_revive(parm[])
 {
    new 
id parm[0], parm[1]
    
spawn(id)
    if(
a==0)
        
get_user_origin(idSOrigin[id])
    else {
        if(
get_pcvar_num(sv_HSRspawns) > 0)
            
spawn_Preset(id)
        else
            
set_user_origin(idSOrigin[id])
    }
 }


 public 
client_connect(id)
 {
    
HSRtime[id] = get_pcvar_float(sv_HSRtime)
 }
 public 
client_putinserver(id)
 {
    
set_task(1.0,"first_respawn",id)
 }
 public 
first_respawn(id)
 {
    if(!
respawn(id))
        
set_task(1.0,"first_respawn",id)
 } 

Last edited by Krtola; 12-09-2014 at 08:37.
Krtola is offline
Send a message via Skype™ to Krtola
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:23.


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