AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   quick help (https://forums.alliedmods.net/showthread.php?t=337447)

Usama Ali 04-21-2022 15:34

quick help
 
the following code is about freezing the first zombie, but its for zp 5.0 so can anyone edit this and make it work for zp 4.3
Code:

#include <amxmodx>
#include <fun>
#include <zp50_core>

#define PLUGIN    "[ZP50] Freeze first zombie"
#define VERSION            "1.0"
#define AUTHOR            "wicho"

#define MarkPlayerSpeed(%0)  bitPlayerSpeed |= (1 << (%0 & 31))
#define ClearPlayerSpeed(%0) bitPlayerSpeed &= ~(1 << (%0 & 31))
#define IsPlayerSpeed(%0)    bitPlayerSpeed & (1 << (%0 & 31))

new bitPlayerSpeed

new cvar_time

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
       
    cvar_time = register_cvar("zp_freeze_frist_zombie", "5.0")
}

public zp_fw_core_infect_post(id)
{   
      if(is_user_alive(id) && zp_core_is_first_zombie(id))
      {
        IsPlayerSpeed(id) = get_user_maxspeed(id)
        set_user_maxspeed(id, 1.0)
        set_task(cvar_time, "Unfreeze", id) 
      }   
}     

public Unfreeze(id)
{
  set_user_maxspeed(id, IsPlayerSpeed(id))
}


OciXCrom 04-21-2022 15:56

Re: quick help
 
#include <zp50_core> => #include <zombieplague>

zp_fw_core_infect_post => zp_user_infected_post

zp_core_is_first_zombie => zp_get_user_first_zombie

Usama Ali 04-21-2022 16:17

Re: quick help
 
Quote:

Originally Posted by OciXCrom (Post 2777491)
#include <zp50_core> => #include <zombieplague>

zp_fw_core_infect_post => zp_user_infected_post

zp_core_is_first_zombie => zp_get_user_first_zombie

SHOWS ERROR

must have value (non-constant)
warning 213 mismatch

Nutu_ 04-21-2022 17:17

Re: quick help
 
the error wasn't even on changes OcixCrom gave you!
There you go!
PHP Code:

#include <amxmodx>
#include <fun>
#include <zombieplague>

#define PLUGIN     "Freeze first zombie"
#define VERSION             "1.0"
#define AUTHOR             "wicho"

#define MarkPlayerSpeed(%0)  bitPlayerSpeed |= (1 << (%0 & 31))
#define ClearPlayerSpeed(%0) bitPlayerSpeed &= ~(1 << (%0 & 31))
#define IsPlayerSpeed(%0)    bitPlayerSpeed & (1 << (%0 & 31))

new bitPlayerSpeed

new cvar_time

public plugin_init() 

    
register_plugin(PLUGINVERSIONAUTHOR
        
    
cvar_time register_cvar("zp_freeze_frist_zombie""5.0")


public 
zp_user_infected_post(id
{     
      if(
is_user_alive(id) && zp_get_user_first_zombie(id))
      {
         
IsPlayerSpeed(id) == get_user_maxspeed(id)
         
set_user_maxspeed(id1.0)
         
set_task(cvar_time"Unfreeze"id)
      }    
}      

public 
Unfreeze(id
{
   
set_user_maxspeed(idIsPlayerSpeed(id))


compiled for me, those 2 tag mismatch, won't do anything to ur server, dont worry!

OciXCrom 04-22-2022 07:08

Re: quick help
 
Actually, they will. The plugin is not written correctly.

Code:
set_task(cvar_time, "Unfreeze", id)

"cvar_time" is a cvar pointer, not a value that can be used within "set_task". This should be "get_pcvar_float(cvar_time)"

Craxor 04-22-2022 09:49

Re: quick help
 
Get_pcvar_float() also reads integers as floats ?
Im worried that he will let an integer value while the plugin will read it as an float? should not you use float() just to br sure ?

I think the best is to let it that way and simply ads float() inside of set task .

Edit: sorry, to use
Code:
set_task(float(get_pcvar_num(cvar_time)), "Unfreeze", id )

CrazY. 04-22-2022 10:57

Re: quick help
 
get_pcvar_float returns a double no matter the value you set the cvar to.

Usama Ali 04-22-2022 11:09

Re: quick help
 
Quote:

Originally Posted by Nutu_ (Post 2777498)
the error wasn't even on changes OcixCrom gave you!
There you go!
PHP Code:

#include <amxmodx>
#include <fun>
#include <zombieplague>

#define PLUGIN     "Freeze first zombie"
#define VERSION             "1.0"
#define AUTHOR             "wicho"

#define MarkPlayerSpeed(%0)  bitPlayerSpeed |= (1 << (%0 & 31))
#define ClearPlayerSpeed(%0) bitPlayerSpeed &= ~(1 << (%0 & 31))
#define IsPlayerSpeed(%0)    bitPlayerSpeed & (1 << (%0 & 31))

new bitPlayerSpeed

new cvar_time

public plugin_init() 

    
register_plugin(PLUGINVERSIONAUTHOR
        
    
cvar_time register_cvar("zp_freeze_frist_zombie""5.0")


public 
zp_user_infected_post(id
{     
      if(
is_user_alive(id) && zp_get_user_first_zombie(id))
      {
         
IsPlayerSpeed(id) == get_user_maxspeed(id)
         
set_user_maxspeed(id1.0)
         
set_task(cvar_time"Unfreeze"id)
      }    
}      

public 
Unfreeze(id
{
   
set_user_maxspeed(idIsPlayerSpeed(id))


compiled for me, those 2 tag mismatch, won't do anything to ur server, dont worry!

It Does not Work.

Craxor 04-22-2022 12:38

Re: quick help
 
Crazy: https://forums.alliedmods.net/showpo...64&postcount=8

But to be sure you can make a test and print the value , set cvar as an Integer and then print the cvar pointer to check if is returning an double .

CrazY. 04-22-2022 12:50

Re: quick help
 
Floating an integer will truncate the decimal part while get_pcvar_float will not, what didn't you understand?
With double I meant float it doesn't matter


All times are GMT -4. The time now is 17:40.

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