Raised This Month: $51 Target: $400
 12% 

quick help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Usama Ali
Member
Join Date: Apr 2020
Old 04-21-2022 , 15:34   quick help
Reply With Quote #1

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))
}
Usama Ali is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-21-2022 , 15:56   Re: quick help
Reply With Quote #2

#include <zp50_core> => #include <zombieplague>

zp_fw_core_infect_post => zp_user_infected_post

zp_core_is_first_zombie => zp_get_user_first_zombie
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Usama Ali
Member
Join Date: Apr 2020
Old 04-21-2022 , 16:17   Re: quick help
Reply With Quote #3

Quote:
Originally Posted by OciXCrom View Post
#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

Last edited by Usama Ali; 04-21-2022 at 16:19.
Usama Ali is offline
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 04-21-2022 , 17:17   Re: quick help
Reply With Quote #4

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!
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-22-2022 , 07:08   Re: quick help
Reply With Quote #5

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)"
__________________

Last edited by OciXCrom; 04-22-2022 at 07:08.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 04-22-2022 , 09:49   Re: quick help
Reply With Quote #6

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 )
__________________
Project: Among Us

Last edited by Craxor; 04-22-2022 at 10:55.
Craxor is offline
Send a message via ICQ to Craxor
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 04-22-2022 , 10:57   Re: quick help
Reply With Quote #7

get_pcvar_float returns a double no matter the value you set the cvar to.
__________________








CrazY. is offline
Usama Ali
Member
Join Date: Apr 2020
Old 04-22-2022 , 11:09   Re: quick help
Reply With Quote #8

Quote:
Originally Posted by Nutu_ View Post
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.
Usama Ali is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 04-22-2022 , 12:38   Re: quick help
Reply With Quote #9

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 .
__________________
Project: Among Us
Craxor is offline
Send a message via ICQ to Craxor
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 04-22-2022 , 12:50   Re: quick help
Reply With Quote #10

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
__________________









Last edited by CrazY.; 04-22-2022 at 12:52.
CrazY. is offline
Old 04-22-2022, 13:35
Craxor
This message has been deleted by Craxor. Reason: Nvm
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:58.


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