Raised This Month: $32 Target: $400
 8% 

[ZP50]Addon: AP change forward


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Catastrophe
Veteran Member
Join Date: Jul 2012
Location: somewhere between narnia
Old 10-14-2014 , 13:04   [ZP50]Addon: AP change forward
Reply With Quote #1

[ZP50] Addon: AP change forward

Found a much better way, Thnx to H.RED.ZONE and Yokomo

Solution: #7
__________________
You will find everything u need :-

Last edited by Catastrophe; 10-16-2014 at 11:12.
Catastrophe is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 10-14-2014 , 13:17   Re: [ZP50]Addon: AP change forward
Reply With Quote #2

Thank you for sharing. ;)

This will be useful.
zmd94 is offline
H.RED.ZONE
Veteran Member
Join Date: Sep 2011
Location: Serbia, Belgrade
Old 10-14-2014 , 13:58   Re: [ZP50]Addon: AP change forward
Reply With Quote #3

You are useing prethink, to check every frame if users ammopacks are changed. If someone wants this type of forward it would be much better way just to check inside zp50_ammopacks when ammopacks are trying to be found in case someone uses your plugin his CPU usage would jump a lot... (Native zp_ammopacks_get) .
Spoiler


And u don't need this amx_settings_api, zp50_core (This one is called inside zp50_ammopacks.inc)
__________________

Last edited by H.RED.ZONE; 10-14-2014 at 14:02.
H.RED.ZONE is offline
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 10-14-2014 , 16:50   Re: [ZP50]Addon: AP change forward
Reply With Quote #4

Welcome back dude, i will check and test the code later..
wicho is offline
Catastrophe
Veteran Member
Join Date: Jul 2012
Location: somewhere between narnia
Old 10-15-2014 , 00:15   Re: [ZP50]Addon: AP change forward
Reply With Quote #5

@H.RED
Check the code and u will find the forward isn't executed every frame its executed after some checks are done and the resultant ammopack change is not 0 I.e when AP are changed.So as of prethink its just does a check or two like many other plugins if not executing the forward. About the include ye sorry I just include everything and then remove what I don't need so I guess I forgot to remove the unused one this time

EDIT: Also the zp_ammopacks_get is a native which is used to get a players current Ap so I didn't quite get what u meant when u wrote that.
__________________
You will find everything u need :-

Last edited by Catastrophe; 10-15-2014 at 00:24.
Catastrophe is offline
H.RED.ZONE
Veteran Member
Join Date: Sep 2011
Location: Serbia, Belgrade
Old 10-15-2014 , 12:08   Re: [ZP50]Addon: AP change forward
Reply With Quote #6

I did check the code, your checks are called inside Prethink. (Meaning it checks every frame and its not like any other plugin)
And "zp_ammopacks_get" is called when u set someones ammopacks = reason (zp_ammopacks_set(id, zp_ammopacks_get(id) + 100) It still calls and if u don't call, it will just set it. And non of the codes that set ammopacks can work if u don't get someones AP first.
__________________

Last edited by H.RED.ZONE; 10-15-2014 at 12:08.
H.RED.ZONE is offline
yokomo
Surprise Ascot!
Join Date: May 2010
Location: Malaysia
Old 10-15-2014 , 13:29   Re: [ZP50]Addon: AP change forward
Reply With Quote #7

Seriously PreThink is overkill lol, just edit "zp50_ammopacks.sma" and call forward on these 2 event.

PHP Code:
public native_ammopacks_set(plugin_idnum_params)
{
    new 
id get_param(1)
    
    if (!
is_user_valid(id))
    {
        
log_error(AMX_ERR_NATIVE"[ZP] Invalid Player (%d)"id)
        return 
false;
    }
    
    new 
amount get_param(2)
    
    
g_AmmoPacks[id] = amount
    ExecuteForward
(Forward_ChangeForward_Resultidg_AmmoPacks[id])
    return 
true;
}

public 
client_putinserver(id)
{
    
g_AmmoPacks[id] = get_pcvar_num(cvar_starting_ammo_packs)
    
ExecuteForward(Forward_ChangeForward_Resultidg_AmmoPacks[id])

__________________
Team-MMG CS1.6 Servers:
✅ MultiMod -- 103.179.44.152:27016
✅ Zombie Plague -- 103.179.44.152:27015
✅ Zombie Escape -- 103.179.44.152:27017
✅ Klassik Kombat -- 103.179.44.152:27018
✅ Boss-Battle -- 103.179.44.152:27019
yokomo is offline
Catastrophe
Veteran Member
Join Date: Jul 2012
Location: somewhere between narnia
Old 10-16-2014 , 11:08   Re: [ZP50]Addon: AP change forward
Reply With Quote #8

@H.RED
i seriously didnt get your reference to zp50_ammopacks_get/set

@yokomo
thnx dude i never thought of that... much appreciated ;)

EDIT: H.RED if u mean wht yokomo said.. then thnx u actually told it to me earlier lol.
EDIT2: oh lol, i didnt actually check the entire code, so now i saw what H.RED gave me in the first code... Sorry ive got a little dumb, all this time ive spent away from scripting T_T
__________________
You will find everything u need :-

Last edited by Catastrophe; 10-16-2014 at 11:15.
Catastrophe is offline
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 12-26-2014 , 02:06   Re: [ZP50]Addon: AP change forward
Reply With Quote #9

Maybe you should give an example of how to use the forward, so people can know how to use it..

Last edited by wicho; 12-26-2014 at 02:09.
wicho is offline
Reply


Thread Tools
Display Modes

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 04:21.


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