AlliedModders

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

RAW_192 07-04-2017 03:13

Run time error
 
Quote:

public event_roundStart()
{
new ent = -1

while((ent = find_ent_by_class(ent, WEAPONBOX)) > 0)
{
task_remove(ent)
weapon_remove(ent)
}

ent = -1

while((ent = find_ent_by_class(ent, ITEM_CLASSNAME)) > 0)
{
task_remove(ent)
entity_remove(ent)
}

for(new id = 1; id < g_iMaxPlayers; id++)
{
if(!g_bAlive[id])
continue

g_bDefuse[id] = false
g_bFreeLook[id] = false
g_fLastBuy[id] = Float:{0.0, 0.0, 0.0, 0.0}

task_remove(id - TASK_EQUIPAMENT)
task_remove(id - TASK_TEAMBALANCE)
task_remove(id - TASK_DEFUSE)

if(g_bRestarting)
{
task_remove(id)
task_remove(id - TASK_ADRENALINE)

g_bRestarted[id] = true
g_iAdrenaline[id] = 0
g_iAdrenalineUse[id] = 0
}

player_updateSpeed(id)
}
//this is line 4954
for(new iFlagTeam = TEAM_RED; iFlagTeam <= TEAM_BLUE; iFlagTeam++)
{
flag_sendHome(iFlagTeam)

task_remove(g_iFlagEntity[iFlagTeam])

log_message("%s, %s flag returned back to base.", (g_bRestarting ? "Game restarted" : "New round started"), g_szTeamName[iFlagTeam])
}

if(g_bRestarting)
{
g_iScore = {0,0,0}
g_bRestarting = false
}
}


PHP Code:

L 07/04/2017 02:58:52: [FUNInvalid player 5
L 07
/04/2017 02:58:52: [AMXXDisplaying debug trace (plugin "jctf.amxx"version "1.34d")
L 07/04/2017 02:58:52: [AMXXRun time error 10native error (native "set_user_maxspeed")
L 07/04/2017 02:58:52: [AMXX]    [0jctf-new.sma::player_updateSpeed (line 5454)
L 07/04/2017 02:58:52: [AMXX]    [1jctf-new.sma::event_roundStart (line 4954)
L 07/04/2017 02:59:14: [FUNInvalid player 5
L 07
/04/2017 02:59:14: [AMXXDisplaying debug trace (plugin "jctf.amxx"version "1.34d")
L 07/04/2017 02:59:14: [AMXXRun time error 10native error (native "set_user_maxspeed")
L 07/04/2017 02:59:14: [AMXX]    [0jctf-new.sma::player_updateSpeed (line 5454)
L 07/04/2017 02:59:14: [AMXX]    [1jctf-new.sma::event_roundStart (line 4954)
L 07/04/2017 02:59:46: [FUNInvalid player 5
L 07
/04/2017 02:59:46: [AMXXDisplaying debug trace (plugin "jctf.amxx"version "1.34d")
L 07/04/2017 02:59:46: [AMXXRun time error 10native error (native "set_user_maxspeed")
L 07/04/2017 02:59:46: [AMXX]    [0jctf-new.sma::player_updateSpeed (line 5454)
L 07/04/2017 02:59:46: [AMXX]    [1jctf-new.sma::event_roundStart (line 4954)
L 07/04/2017 03:00:25: [FUNInvalid player 2
L 07
/04/2017 03:00:25: [AMXXDisplaying debug trace (plugin "jctf.amxx"version "1.34d")
L 07/04/2017 03:00:25: [AMXXRun time error 10native error (native "set_user_maxspeed")
L 07/04/2017 03:00:25: [AMXX]    [0jctf-new.sma::player_updateSpeed (line 5454)
L 07/04/2017 03:00:25: [AMXX]    [1jctf-new.sma::event_roundStart (line 4954


CrazY. 07-04-2017 22:51

Re: Run time error
 
Code:
while((ent = find_ent_by_class(ent, ITEM_CLASSNAME)) > 0)
?

Why not?
Code:
while ((ent = find_ent_by_class(-1, ITEM_CLASSNAME)) if (is_valid_ent(ent)) remove_entity(ent)


Quote:

[FUN] Invalid player 5
Probrably you didn't check if the user is alive.

Craxor 07-05-2017 01:12

Re: Run time error
 
The error says that the player is not valid, it can mean that user with Index '5' doesn't not exit or (i'm not sure at this hour because i'm very sleepy) it is not alive, as CrazY say you can add an is_user_alive() filter.

But i'm giving you an friendly advice and say that you should give-up checking for players with this method:

PHP Code:

for(new id 1id g_iMaxPlayersid++)


Better use get_players() also in that way you can also use the flag "a" and leave is_user_alive().

Natsheh 07-05-2017 01:55

Re: Run time error
 
There isnt enough code provided....

And Crazy its unnecessary to check if entity is valid...
Since find ent returns a vaild entities id if its above 0

And as craxor said it would be better if you looped throw get players instead of get maxplayers , it would better to loop throw all maxplayers if you wanted to reset players arrays.... And not execute .actions on them

CrazY. 07-05-2017 10:15

Re: Run time error
 
Quote:

And Crazy its unnecessary to check if entity is valid...
Since find ent returns a vaild entities id if its above 0

Aah, ok.


All times are GMT -4. The time now is 22:50.

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