AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   whats wrong with conditions (https://forums.alliedmods.net/showthread.php?t=192803)

avril-lavigne 08-14-2012 08:30

whats wrong with conditions
 
PHP Code:

public fwdPlayerSpawn(id)
{
     if(!
is_user_alive(id) && (!is_user_admin(id)))
     return 
PLUGIN_CONTINUE

     ShowAdminMenu
(id
     
set_user_footsteps(id1)
    
//set_user_frags(id,get_user_frags(id) + 1)
     
     
return PLUGIN_CONTINUE


I have is logs [FUN] invalid player id ( native set_user_footsteps )

but plugin is working fine

Exolent[jNr] 08-14-2012 09:30

Re: whats wrong with conditions
 
Quote:

Originally Posted by avril-lavigne (Post 1771118)
PHP Code:

public fwdPlayerSpawn(id)
{
     if(!
is_user_alive(id) && (!is_user_admin(id)))
     return 
PLUGIN_CONTINUE 


This will work for:
- all alive players
- all dead non-admins

This won't work for:
- dead admins

This will break on players that aren't connected yet.

Change && to ||

bibu 08-14-2012 11:03

Re: whats wrong with conditions
 
I believe you hook spawn with ham, so use its' own returns. Also, you could change it easy to this ->

PHP Code:

public fwdPlayerSpawn(id

     if(
is_user_alive(id) && is_user_admin(id)) 
     {
          
ShowAdminMenu(id)  
          
set_user_footsteps(id1
          
//set_user_frags(id,get_user_frags(id) + 1) 
     
}



avril-lavigne 08-14-2012 11:36

Re: whats wrong with conditions
 
thanks bibu


All times are GMT -4. The time now is 05:51.

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