AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   pfn_touch error (https://forums.alliedmods.net/showthread.php?t=129293)

cs1.7 06-11-2010 09:02

pfn_touch error
 
1 Attachment(s)
hi

what's the problem in this code? It gives the below error message constantly and often crashes the server.

Code:

L 06/11/2010 - 14:53:48: [ENGINE] Invalid entity 291
L 06/11/2010 - 14:53:48: [AMXX] Displaying debug trace (plugin "portal.amxx")
L 06/11/2010 - 14:53:48: [AMXX] Run time error 10: native error (native "entity_
get_string")
L 06/11/2010 - 14:53:48: [AMXX]    [0] portal.sma::pfn_touch (line 317)
L 06/11/2010 - 14:54:40: [ENGINE] Invalid entity 289
L 06/11/2010 - 14:54:40: [AMXX] Displaying debug trace (plugin "portal.amxx")
L 06/11/2010 - 14:54:40: [AMXX] Run time error 10: native error (native "entity_
get_string")
L 06/11/2010 - 14:54:40: [AMXX]    [0] portal.sma::pfn_touch (line 317)

PHP Code:

/* AMX Portal
*
* (c) Copyright 2005, KleeneX
* This file is provided as is (no warranties).
*
*/

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <engine>

#define MAX_PORTALS    10
#define MAX_TARGETS    10
#define MAX_ALLROUNDS    10
#define MAX_BLACKHOLES    10
#define MAX_STARGATEIN 10
#define MAX_STARGATEOUT 10

#define ADMIN_FLAG     ADMIN_LEVEL_A
new sgportal_model[64] = "sprites/portal1.spr"
new sgtarget_model[64] = "sprites/portal1.spr"

new portal_model[64] = "sprites/e-tele1.spr"
new target_model[64] = "sprites/b-tele1.spr"
new allround_model[64] = "sprites/exit1.spr"
new blackhole_model[64] = "models/blackhole.mdl"

new spr_portalspr_target;

new 
cfgFolder[50], mapName[50];
#include "portal.inc"


public plugin_precache() {
    
    
precache_model(portal_model)
    
precache_model(target_model)
    
precache_model(allround_model)
    
precache_model(blackhole_model)
    
    
spr_portal=precache_model(sgportal_model)
    
spr_target=precache_model(sgtarget_model)
    
precache_sound("debris/beamstart1.wav")
    
precache_sound("debris/beamstart7.wav")
    
    
precache_model("models/gate2.mdl")
    
precache_sound("misc/sg1_siren.wav")
    
precache_sound("misc/chevron.wav")
}

public 
plugin_init() {
    
register_plugin("AMX Portal""1.4""KleeneX")
    
register_clcmd("amx_portal","create_portal",ADMIN_FLAG,": Create a Portal")
    
register_clcmd("amx_ptarget","create_target",ADMIN_FLAG,": Create a Portal Target")
    
register_clcmd("amx_aportal","create_allround",ADMIN_FLAG,": Create a Allround")
    
register_clcmd("amx_blackhole","create_blackhole",ADMIN_FLAG,": Create a Blackhole")
    
    
register_clcmd("amx_r_portal","remove_portal",ADMIN_FLAG,": Remove all Portals")
    
register_clcmd("amx_r_ptarget","remove_target",ADMIN_FLAG,": Remove all Targets")
    
register_clcmd("amx_r_aportal","remove_allround",ADMIN_FLAG,": Remove all Allrounds")
    
register_clcmd("amx_r_blackhole","remove_blackhole",ADMIN_FLAG,": Remove all Blackholes")
    
    
register_clcmd("amx_sgportal","create_sgportal",ADMIN_FLAG,":Create a Portal")
    
register_clcmd("amx_sgptarget","create_sgtarget",ADMIN_FLAG,":Create a Portal Target")
    
    
register_clcmd("amx_r_sgportal","remove_sgportal",ADMIN_FLAG,":Create a Stargate Portal")
    
register_clcmd("amx_r_sgptarget","remove_sgtarget",ADMIN_FLAG,":Create a Stargate Portal Target")
    
    
    
register_clcmd("amx_portalmenu","cmdPortalMenu",ADMIN_FLAG,": Open the Portal Menu")
    
register_clcmd("amx_portalmenu2","cmdPortalMenu2",ADMIN_FLAG,": Open the Portal Menu2")
    
register_menucmd(register_menuid("\rPortal Menu:"),1023,"actionPortalMenu")
    
register_menucmd(register_menuid("\rPortal Menu2:"),1023,"actionPortalMenu2")
    
get_configsdir(cfgFolder,49);
    
get_mapname(mapName,49);
    
register_concmd("saveportals","savePortals",ADMIN_FLAG,": save portals");
    
loadPortals();
}

public 
create_portal(id,level,cid) {
    if (!
cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
    
if(numPortals == MAX_PORTALS) {
        
console_print(id"Too many portals.")
        return 
PLUGIN_HANDLED
    
}
    
    new 
Origin[3]
    
get_user_origin(id,Origin)
    
    new 
Float:pOrigin[3]
    
IVecFVec(OriginFloat:pOrigin);
    
pOrigin[1] += 50
    create_ent_portal
(pOrigin);
    return 
PLUGIN_HANDLED
}

public 
create_target(id,level,cid) {
    if (!
cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
    
if(numTargets == MAX_TARGETS) {
        
console_print(id"Too many targets.")
        return 
PLUGIN_HANDLED
    
}
    new 
Origin[3]
    
get_user_origin(id,Origin)
    
    new 
Float:pOrigin[3]
    
IVecFVec(OriginFloat:pOrigin)
    
pOrigin[1] += 50
    create_ent_target
(pOrigin);
    return 
PLUGIN_HANDLED
}

public 
create_allround(id,level,cid) {
    if (!
cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
    
if(numAllrounds == MAX_ALLROUNDS) {
        
console_print(id"Too many allrounds.")
        return 
PLUGIN_HANDLED
    
}
    
    new 
Origin[3]
    
get_user_origin(id,Origin)
    new 
Float:pOrigin[3]
    
IVecFVec(OriginFloat:pOrigin)
    
pOrigin[1] += 50
    create_ent_allround
(pOrigin);
    return 
PLUGIN_HANDLED
}

public 
create_blackhole(id,level,cid) {
    if (!
cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
    
if(numBlackholes == MAX_BLACKHOLES) {
        
console_print(id"Too many blackholes.")
        return 
PLUGIN_HANDLED
    
}
    new 
Float:vOrigin[3]
    new 
Float:vAngles[3]
    
entity_get_vector(idEV_VEC_originvOrigin)
    
entity_get_vector(idEV_VEC_v_anglevAngles)
    new 
Float:vNewOrigin[3]
    new 
Float:vNormal[3]
    new 
Float:vTraceDirection[3]
    new 
Float:vTraceEnd[3]
    new 
Float:vTraceResult[3]
    new 
Float:vEntAngles[3]
    
    
VelocityByAim(id64vTraceDirection)
    
    
vTraceEnd[0] = vTraceDirection[0] + vOrigin[0]
    
vTraceEnd[1] = vTraceDirection[1] + vOrigin[1]
    
vTraceEnd[2] = vTraceDirection[2] + vOrigin[2]
    
    
trace_line(idvOriginvTraceEndvTraceResult)
    new 
bool:bad=(trace_normal(idvOriginvTraceEndvNormal) == 0);
    
vNewOrigin[0] = vTraceResult[0] + (vNormal[0] * 10.0)
    
vNewOrigin[1] = vTraceResult[1] + (vNormal[1] * 10.0)
    
vNewOrigin[2] = vTraceResult[2] + (vNormal[2] * 10.0)
    
vector_to_angle(vNormalvEntAngles);
    
    new 
blackhole=create_ent_blackhole(vNewOriginvEntAngles);
    if(
bad) {
        
remove_entity(blackhole)
        
console_print(id"You must create a blackhole on a wall!")
        
numBlackholes--;
        return 
PLUGIN_HANDLED_MAIN
    
}
    return 
PLUGIN_HANDLED;
}
public 
create_sgportal(id,level,cid) {
    if (!
cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
    
if(numStargateIn == MAX_STARGATEIN
    {
        
console_print(id"Too many SG portals.")
        return 
PLUGIN_HANDLED
    
}
    
    new 
Float:pOrigin[3]
    
entity_get_vector(idEV_VEC_originpOrigin)
    new 
Float:portal_angles[3
    
entity_get_vector(idEV_VEC_v_angleportal_angles
    
create_ent_sgportal(pOriginportal_angles,true);
    
    return 
PLUGIN_HANDLED
}

public 
create_sgtarget(id,level,cid) {
    if (!
cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
    
if(numStargateOut == MAX_STARGATEOUT
    {
        
console_print(id"Too many SG targets.")
        return 
PLUGIN_HANDLED
    
}
    new 
Float:pOrigin[3]
    
entity_get_vector(idEV_VEC_originpOrigin)
    new 
Float:portal_angles[3
    
entity_get_vector(idEV_VEC_v_angleportal_angles
    
create_ent_sgtarget(pOrigin,portal_angles);
    
    return 
PLUGIN_HANDLED
}

public 
remove_portal(id,level,cid) {
    if (!
cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
    
for(new 0numPortalsa++) {
        
remove_entity(mapPortals[a])
    }
    
numPortals 0
    
return PLUGIN_HANDLED
}

public 
remove_target(id,level,cid) {
    if (!
cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
    
for(new 0numTargetsa++) {
        
remove_entity(mapTargets[a])
    }
    
numTargets 0
    
return PLUGIN_HANDLED
}

public 
remove_allround(id,level,cid) {
    if (!
cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
    
for(new 0numAllroundsa++) {
        
remove_entity(mapAllrounds[a])
    }
    
numAllrounds 0
    
return PLUGIN_HANDLED
}

public 
remove_blackhole(id,level,cid) {
    if (!
cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
    
for(new 0numBlackholesa++) {
        
remove_entity(mapBlackholes[a])
    }
    
numBlackholes 0
    
return PLUGIN_HANDLED
}
public 
remove_sgportal(id,level,cid) {
    if (!
cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
    
for(new 0numStargateIna++) {
        
remove_entity(mapStargateIn[a])
    }
    
numStargateIn 0
    
return PLUGIN_HANDLED
}

public 
remove_sgtarget(id,level,cid) {
    if (!
cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
    
for(new 0numStargateOuta++) {
        
remove_entity(mapStargateOut[a])
    }
    
numStargateOut 0
    
return PLUGIN_HANDLED
}
public 
server_frame() {
    for(new 
0<= numPortals; ++a) {
        if(
is_valid_ent(mapPortals[a])) {
            if(
entity_get_float(mapPortals[a], EV_FL_frame) < 0.0 || entity_get_float(mapPortals[a], EV_FL_frame) > 25) {
                
entity_set_float(mapPortals[a], EV_FL_frame0.0)
            }
            else 
entity_set_float(mapPortals[a], EV_FL_frameentity_get_float(mapPortals[a], EV_FL_frame) + 0.5)
        }
    }
    for(new 
0<= numTargets; ++a) {
        if(
is_valid_ent(mapTargets[a])) {
            if(
entity_get_float(mapTargets[a], EV_FL_frame) < 0.0 || entity_get_float(mapTargets[a], EV_FL_frame) > 25) {
                
entity_set_float(mapTargets[a], EV_FL_frame0.0)
            }
            else 
entity_set_float(mapTargets[a], EV_FL_frameentity_get_float(mapTargets[a], EV_FL_frame) + 0.5)
        }
    }
    for(new 
0<= numAllrounds; ++a) {
        if(
is_valid_ent(mapAllrounds[a])) {
            if(
entity_get_float(mapAllrounds[a], EV_FL_frame) < 0.0 || entity_get_float(mapAllrounds[a], EV_FL_frame) > 25) {
                
entity_set_float(mapAllrounds[a], EV_FL_frame0.0)
            }
            else 
entity_set_float(mapAllrounds[a], EV_FL_frameentity_get_float(mapAllrounds[a], EV_FL_frame) + 0.5)
        }
    }
    for(new 
0<= numBlackholes; ++a) {
        if(
is_valid_ent(mapBlackholes[a])) {
            if(
entity_get_float(mapBlackholes[a], EV_FL_frame) < 195.0 || entity_get_float(mapBlackholes[a], EV_FL_frame) > 255) {
                
entity_set_float(mapBlackholes[a], EV_FL_frame195.0)
            }
            else 
entity_set_float(mapBlackholes[a], EV_FL_frameentity_get_float(mapBlackholes[a], EV_FL_frame) + 1.5)
        }
    }
    new 
Float:new_frame get_gametime()
    
    if( (
new_frame last_frame) >= ( 1.0 framerate) ) 
    {
    
last_frame new_frame 
    
    
for(new 0numStargateIn; ++a
    {
        if(
is_valid_ent(mapStargateIn[a])) 
        {
            
entity_set_int(mapStargateIn[a], EV_INT_sequence1)
            
            
frame[a] += 5.0 
            
if(frame[a] >= 254.0)
            {
                
frame[a] = 0.0
            
}
            
entity_set_float(mapStargateIn[a], EV_FL_frameframe[a]) 
            if(
frame[a] == 25 || frame[a] == 65 || frame[a] == 175 || frame[a] == 210 || frame[a] == 250)
            {
                
emit_sound(mapStargateIn[a], CHAN_WEAPON"misc/chevron.wav"0.42.60PITCH_NORM)
            }
        } 
    }
    }
}

public 
pfn_touch(ptr,ptd) {
    if (
ptr && ptd 0) {
        new 
Portal[32]
        
entity_get_string(ptrEV_SZ_classnamePortal31)
        if ( 
equal(Portal,"amx_portal") ) {
            if(
numTargets == 0) return PLUGIN_HANDLED
            
else{
                new 
random_targetOrigin[3]
                new 
Float:eOrigin[3]
                
random_target mapTargets[random_num(0,numTargets 1)]
                
entity_get_vector(random_targetEV_VEC_origineOrigin )
                
FVecIVec(Float:eOrigin,Origin)
                
                
Origin[0] += 80
                Origin
[1] += 80
                Origin
[2] += 10
                
                
new Float:velocity[3]
                
entity_get_vector(ptdEV_VEC_velocityvelocity)
                
emit_sound(ptrCHAN_WEAPON"debris/beamstart1.wav"0.4ATTN_NORM0PITCH_NORM)
                
                
set_user_origin(ptd,Origin)
                
                
velocity[2] = random_float(200.0225.0)
                
entity_set_vector(ptdEV_VEC_velocityvelocity)
                
emit_sound(random_targetCHAN_WEAPON"debris/beamstart7.wav"0.4ATTN_NORM0PITCH_NORM)
            }
        }
        if ( 
equal(Portal,"amx_aportal") ) {
            if(
numAllrounds == 1) return PLUGIN_HANDLED
            
else{
                new 
random_targetOrigin[3]
                new 
Float:eOrigin[3]
                
random_target mapAllrounds[random_num(0,numAllrounds 1)]
                if(
random_target != ptr) {
                    
entity_get_vector(random_targetEV_VEC_origineOrigin )
                    
FVecIVec(Float:eOrigin,Origin)
                    
                    
Origin[0] += 80
                    Origin
[1] += 80
                    Origin
[2] += 10
                    
                    
new Float:velocity[3]
                    
entity_get_vector(ptdEV_VEC_velocityvelocity)
                    
emit_sound(ptrCHAN_WEAPON"debris/beamstart1.wav"0.4ATTN_NORM0PITCH_NORM)
                    
                    
set_user_origin(ptd,Origin)
                    
                    
velocity[2] = random_float(200.0225.0)
                    
entity_set_vector(ptdEV_VEC_velocityvelocity)
                    
emit_sound(random_targetCHAN_WEAPON"debris/beamstart7.wav"0.4ATTN_NORM0PITCH_NORM)
                }
            }
        }
        if ( 
equal(Portal,"amx_blackhole") ) {
            if(
numBlackholes == 1) {
                
//user_kill(ptd,1)
                
return PLUGIN_HANDLED
                
}else{
                new 
random_target
                
new Float:eOrigin[3]
                
random_target mapBlackholes[random_num(0,numBlackholes 1)]
                if(
random_target != ptr) {
                    
entity_get_vector(random_targetEV_VEC_origineOrigin )
                    
                    new 
Float:vEntAngles[3]
                    
entity_get_vector(random_targetEV_VEC_anglesvEntAngles)
                    
                    if(
vEntAngles[0] < 181)
                    
eOrigin[2] += 50
                    
else if(vEntAngles[0] < 361)    
                    
eOrigin[2] -= 50
                    
                    
if(vEntAngles[1] == 0)
                    
eOrigin[0] += 80
                    
else if(vEntAngles[1] < 91)
                    
eOrigin[1] += 80
                    
else if(vEntAngles[1] < 181)
                    
eOrigin[0] -= 80
                    
else if(vEntAngles[1] < 271)
                    
eOrigin[1] -= 80
                    
                    
new Float:velocity[3]
                    new 
players[32],pnum
                    get_players
(players,pnum)
                    
entity_get_vector(ptdEV_VEC_velocityvelocity)
                    
                    
emit_sound(ptrCHAN_WEAPON"debris/beamstart1.wav"0.4ATTN_NORM0PITCH_NORM)
                    
entity_set_vector(ptd,EV_VEC_origin,eOrigin)
                    
emit_sound(random_targetCHAN_WEAPON"debris/beamstart7.wav"0.4ATTN_NORM0PITCH_NORM)
                    
                    if(
vEntAngles[0] < 361 && vEntAngles[0] > 180)    
                    
velocity[2] = random_float(-200.0, -225.0)
                    else
                    
velocity[2] = random_float(200.0225.0)
                    
entity_set_vector(ptdEV_VEC_velocityvelocity)
                }
            }
        }
        if ( 
equal(Portal,"amx_sgportal") ) {
            if(
numStargateOut == 0) return PLUGIN_CONTINUE
            
else{
                new 
random_targetOrigin[3]
                new 
Float:eOrigin[3]
                
random_target mapStargateOut[random_num(0,numTargets 1)]
                
entity_get_vector(random_targetEV_VEC_origineOrigin )
                
                
emit_sound(ptrCHAN_WEAPON"misc/sg1_siren.wav"0.6ATTN_STATIC0PITCH_NORM)
                
                new 
Float:velocity[3]
                
entity_get_vector(ptdEV_VEC_velocityvelocity)
                
                
FVecIVec(Float:eOrigin,Origin)
                
Origin[2] += 10
                set_user_origin
(ptd,Origin)
                
                
emit_sound(random_targetCHAN_WEAPON"misc/sg1_siren.wav"0.6ATTN_STATIC0PITCH_NORM)
                
                
velocity[2] = random_float(200.0225.0)
                
entity_set_vector(ptdEV_VEC_velocityvelocity)
            }
        }
        if ( 
equal(Portal,"amx_sgptarget") ) {
            if(
numAllrounds == 1) return PLUGIN_CONTINUE
            
else{
                new 
random_targetOrigin[3]
                new 
Float:eOrigin[3]
                
random_target mapAllrounds[random_num(0,numAllrounds 1)]
                if(
random_target != ptr) {
                    
entity_get_vector(random_targetEV_VEC_origineOrigin )
                    
FVecIVec(Float:eOrigin,Origin)
                    
                    
emit_sound(ptrCHAN_WEAPON"debris/beamstart1.wav"0.4ATTN_NORM0PITCH_NORM)
                    
                    
Origin[0] += 40
                    Origin
[1] += 40
                    Origin
[2] += 10
                    
                    
new Float:velocity[3]
                    
//entity_get_vector(ptd, EV_VEC_velocity, velocity)
                    
                    
set_user_origin(ptd,Origin)
                    
                    
emit_sound(random_targetCHAN_WEAPON"debris/beamstart7.wav"0.4ATTN_NORM0PITCH_NORM)
                    
                    
//velocity[2] = random_float(200.0, 225.0)
                    
entity_set_vector(ptdEV_VEC_velocityvelocity)
                }
            }
        }
    }
    return 
PLUGIN_CONTINUE
}

public 
cmdPortalMenu(id,level,cid) {
    if (!
cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
    displayPortalMenu
(id)
    return 
PLUGIN_HANDLED
}

public 
displayPortalMenu(id) {
    new 
MenuBody[256], keys
    
    
new nLen formatMenuBody255"\rPortal Menu:^n" )
    
    if (
numPortals == MAX_PORTALSnLen += formatMenuBody[nLen], 255-nLen,"^n\w1. Create Portal \r(Limit reached)")
    else 
nLen += formatMenuBody[nLen], 255-nLen"^n\w1. Create Portal" )
    if (
numTargets == MAX_TARGETSnLen += formatMenuBody[nLen],255-nLen,"^n\w2. Create Target \r(Limit reached)")
    else 
nLen += formatMenuBody[nLen],255-nLen,"^n\w2. Create Target")
    if (
numAllrounds == MAX_ALLROUNDSnLen += formatMenuBody[nLen],255-nLen,"^n\w3. Create Allround \r(Limit reached)")
    else 
nLen += formatMenuBody[nLen],255-nLen,"^n\w3. Create Allround")
    if (
numBlackholes == MAX_BLACKHOLESnLen += formatMenuBody[nLen],255-nLen,"^n\w4. Create Blackhole \r(Limit reached)^n")
    else 
nLen += formatMenuBody[nLen],255-nLen,"^n\w4. Create Blackhole^n")
    
nLen += formatMenuBody[nLen], 255-nLen"^n\w5. Remove Portals" )
    
nLen += formatMenuBody[nLen], 255-nLen"^n\w6. Remove Targets" )
    
nLen += formatMenuBody[nLen], 255-nLen"^n\w7. Remove Allround" )
    
nLen += formatMenuBody[nLen], 255-nLen"^n\w8. Remove Blackholes^n" )
    
nLen += formatMenuBody[nLen], 255-nLen"^n\w9. Save^n" )
    
nLen += formatMenuBody[nLen], 255-nLen"^n\y0. Exit" )
    
    
keys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9)
    
    
show_menuidkeysMenuBody, -1)
    
    return 
PLUGIN_CONTINUE
}

public 
actionPortalMenu(id,key) {
    new 
cidlevel
    
switch(key) {
        case 
0create_portal(id,level,cid)
        case 
1create_target(id,level,cid)
        case 
2create_allround(id,level,cid)
        case 
3create_blackhole(id,level,cid)
        case 
4remove_portal(id,level,cid)
        case 
5remove_target(id,level,cid)
        case 
6remove_allround(id,level,cid)
        case 
7remove_blackhole(id,level,cid)
        case 
8savePortals(id,level,cid)
    }
    if (
key != 9displayPortalMenu(id)
    return 
PLUGIN_HANDLED
}

public 
cmdPortalMenu2(id,level,cid) {
    if (!
cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
    displayPortalMenu2
(id)
    return 
PLUGIN_HANDLED
}
public 
displayPortalMenu2(id) {
    new 
MenuBody[256], keys
    
    
new nLen formatMenuBody255"\rPortal Menu2:^n" )
    
    if (
numStargateIn == MAX_STARGATEINnLen += formatMenuBody[nLen], 255-nLen,"^n\w1. Create Stargate Portal \r(Limit reached)")
    else 
nLen += formatMenuBody[nLen], 255-nLen"^n\w1. Create Stargate Portal" )
    if (
numStargateOut == MAX_STARGATEOUTnLen += formatMenuBody[nLen],255-nLen,"^n\w2. Create Stargate Target \r(Limit reached)")
    else 
nLen += formatMenuBody[nLen],255-nLen,"^n\w2. Create Stargate Target")
    
nLen += formatMenuBody[nLen], 255-nLen"^n^n\w3. Remove Portals" )
    
nLen += formatMenuBody[nLen], 255-nLen"^n\w4. Remove Targets" )
    
nLen += formatMenuBody[nLen], 255-nLen"^n^n\w9. Save^n" )
    
nLen += formatMenuBody[nLen], 255-nLen"^n\y0. Exit" )
    
    
keys = (1<<0|1<<1|1<<2|1<<3|1<<8|1<<9)
    
    
show_menuidkeysMenuBody, -1)
    
    return 
PLUGIN_CONTINUE
}

public 
actionPortalMenu2(id,key) {
    new 
cidlevel
    
switch(key) {
        case 
0create_sgportal(id,level,cid)
        case 
1create_sgtarget(id,level,cid)
        case 
2remove_sgportal(id,level,cid)
        case 
3remove_sgtarget(id,level,cid)
        case 
8savePortals(id,level,cid)
    }
    if (
key != 9displayPortalMenu2(id)
    return 
PLUGIN_HANDLED
}


public 
draw_sgportal(id
{
    if(!
is_valid_ent(id))
    return 
PLUGIN_HANDLED
    
    
new spriteorigin[3], Float:spriteoriginF[3]
    
entity_get_vector(idEV_VEC_originspriteoriginF)
    
FVecIVec(spriteoriginF,spriteorigin)
    
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
    
write_byte(17)
    
write_coord(spriteorigin[0])
    
write_coord(spriteorigin[1]) 
    
write_coord(spriteorigin[2])
    
write_short(spr_portal
    
write_byte(30)
    
write_byte(255)
    
message_end()
    
    
set_task(2.0"draw_sgportal"id)
    
    return 
PLUGIN_HANDLED
}
public 
draw_sgtarget(id
{
    if(!
is_valid_ent(id))
    return 
PLUGIN_HANDLED
    
    
new spriteorigin[3], Float:spriteoriginF[3]
    
entity_get_vector(idEV_VEC_originspriteoriginF)
    
FVecIVec(spriteoriginF,spriteorigin)
    
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
    
write_byte(17)
    
write_coord(spriteorigin[0])
    
write_coord(spriteorigin[1]) 
    
write_coord(spriteorigin[2])
    
write_short(spr_target
    
write_byte(30)
    
write_byte(255)
    
message_end()
    
    
set_task(2.0"draw_sgtarget"id)
    
    return 
PLUGIN_HANDLED



Arkshine 06-11-2010 09:51

Re: pfn_touch error
 
check if ptr/ptd is valid. ( pev_valid )

Alucard^ 06-11-2010 10:09

Re: pfn_touch error
 
or is_valid_ent(ent) :p

cs1.7 06-11-2010 10:31

Re: pfn_touch error
 
in which function do i have to add this check? Could you show me where? :)

Arkshine 06-11-2010 11:07

Re: pfn_touch error
 
L 06/11/2010 - 14:53:48: [AMXX] [0] portal.sma::pfn_touch (line 317)

cs1.7 06-11-2010 11:57

Re: pfn_touch error
 
thx :)

i added the check like this:

Line 316:
PHP Code:

    if (ptr && ptd && pev_valid(ptr) && pev_valid(ptd)) { 

and also included:

PHP Code:

#include <fakemeta> 

It compiled flawlessly. :)


edit:

Damn, now i'm getting this error:

Code:

L 06/13/2010 - 00:48:33: [AMXX]    [0] portal.sma::pfn_touch (line 336)
L 06/13/2010 - 00:48:33: [FUN] Player out of range (358)
L 06/13/2010 - 00:48:33: [AMXX] Displaying debug trace (plugin "portal.amxx")
L 06/13/2010 - 00:48:33: [AMXX] Run time error 10: native error (native "set_use
r_origin")
L 06/13/2010 - 00:48:33: [AMXX]    [0] portal.sma::pfn_touch (line 336)
L 06/13/2010 - 00:48:33: [FUN] Player out of range (359)
L 06/13/2010 - 00:48:33: [AMXX] Displaying debug trace (plugin "portal.amxx")
L 06/13/2010 - 00:48:33: [AMXX] Run time error 10: native error (native "set_use
r_origin")


Arkshine 06-12-2010 19:53

Re: pfn_touch error
 
Check if ptr is a player, you can use is_user_alive()

cs1.7 06-12-2010 21:24

Re: pfn_touch error
 
i added this check and the portals have stopped to work. That means touching them won't do anything anymore.

PHP Code:

public pfn_touch(ptr,ptd) {
    if (
ptr && ptd && pev_valid(ptr) && pev_valid(ptd) && is_user_alive(ptr) ) { 


Alucard^ 06-12-2010 22:27

Re: pfn_touch error
 
If you are using pev_valid() then prtr > 0 is useless... (i am not sure)... also the same with is_user_alive()

ConnorMcLeod 06-13-2010 04:59

Re: pfn_touch error
 
Replace :

Code:
    if (ptr > 0 && ptd > 0) {

with

Code:
    if (ptr > 0 && ptd > 0 && is_valid_ent(ptr) && is_user_alive(ptd) ) {


All times are GMT -4. The time now is 14:53.

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