AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   SuperHero Tracker Invalid player id 0 problem (https://forums.alliedmods.net/showthread.php?t=308734)

gameplayonline 07-01-2018 10:30

SuperHero Tracker Invalid player id 0 problem
 
Hello i have this code:
Code:

public tracker_damage(id)
{
  new victim
  victim = id
  new attacker
  if (get_user_attacker(victim) > 0) 
        attacker = get_user_attacker(victim)
  else
        return PLUGIN_CONTINUE
 
  new maxTargets = get_cvar_num("tracker_maxtargets")
 
  if(maxTargets == 0)
    maxTargets = 33
   
  if ( attacker <= 0 || attacker > 33 || victim <= 0 || victim > 33)
        return PLUGIN_CONTINUE 

  if (victim==0)
        return PLUGIN_CONTINUE 
 
  if(attacker > 0 && attacker <= 33 && victim > 0 && victim <= 33 && hasTrackerPowers[attacker] && attacker!=victim && get_user_team(attacker)!=get_user_team(victim) && numTargets[attacker]<maxTargets)
  {
    isTagged[attacker][victim] = true
    numTargets[attacker] = numTargets[attacker]++
    timeLeft[attacker][victim] = get_cvar_float("tracker_timetargeted")
    if(timeLeft[attacker][victim]==0.0)
      timeLeft[attacker][victim] = -1.0
  }
  else
        return PLUGIN_CONTINUE 
       
  return PLUGIN_CONTINUE
}

My problem is this error in error log:
Code:

L 07/01/2018 - 12:02:16: Invalid player id 0
L 07/01/2018 - 12:02:16: [AMXX] Displaying debug trace (plugin "sh_tracker.amxx")
L 07/01/2018 - 12:02:16: [AMXX] Run time error 10: native error (native "get_user_attacker")
L 07/01/2018 - 12:02:16: [AMXX]    [0] sh_tracker.sma::tracker_damage (line 105)
L 07/01/2018 - 12:04:12: Invalid player id 0

I tried fix it but still im not able to fix. Can somebody help me please?

maqi 07-01-2018 10:35

Re: SuperHero Tracker Invalid player id 0 problem
 
Simply check if victim is 1 to max clients and/or is_user_connected()

fysiks 07-01-2018 14:40

Re: SuperHero Tracker Invalid player id 0 problem
 
Just is_user_connected() is required here.

gameplayonline 07-01-2018 16:43

Re: SuperHero Tracker Invalid player id 0 problem
 
Thanks


All times are GMT -4. The time now is 12:24.

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