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

I need help fix code


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mrzonxino
Junior Member
Join Date: Sep 2014
Old 09-24-2014 , 06:48   I need help fix code
Reply With Quote #1

I need help fix code, please. It only run zp_health_respawn1 also zp_health_respawn2 not run.


Quote:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>
#include <zombieplague>
#include <fakemeta>
#include <engine>
#include <fun>
#define PLUGIN "Respawn time level"
#define VERSION "1.0"
#define AUTHOR "mrzonxino"

new cvar_health_respawn1 , cvar_health_respawn2
new g_respawn_count[33]

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)

RegisterHam(Ham_Spawn, "player", "fw_PlayerRespawn", 1)
cvar_health_respawn1 = register_cvar("zp_health_respawn1", "1500")
cvar_health_respawn2 = register_cvar("zp_health_respawn2", "3000")
}

public fw_PlayerRespawn(id)
{
set_task(1.0, "PlayerRespawn", id)
}

public PlayerRespawn(id)
{
if zp_get_user_zombie(id)
return PLUGIN_CONTINUE;

if (g_respawn_count[id] = 1 )
{
set_user_health(id, get_user_health(id) + get_pcvar_num(cvar_health_respawn1))
}
esle if (g_respawn_count[id] = 2 )
{
set_user_health(id, get_user_health(id) + get_pcvar_num(cvar_health_respawn2))
}

}
mrzonxino is offline
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 09-24-2014 , 07:08   Re: I need help fix code
Reply With Quote #2

Look at g_respawn_count and tell me what's wrong;)

Last edited by RateX; 09-24-2014 at 07:08.
RateX is offline
mrzonxino
Junior Member
Join Date: Sep 2014
Old 09-24-2014 , 07:44   Re: I need help fix code
Reply With Quote #3

i dont know...i just started learn amxx .please, help me

Last edited by mrzonxino; 09-24-2014 at 07:49.
mrzonxino is offline
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 09-24-2014 , 08:40   Re: I need help fix code
Reply With Quote #4

You are checking if that variable is 1 or 2 so you can execute your functions, yet you didn't even give it a value to be checked.
Add this before set_task:
PHP Code:
g_respawn_count[id]++
If(
g_respawn_count[id] > 2g_respawn_count[id] = 
Also, you can just include amxmodx, zombieplague, fun and hamsandwich, as the others are completely unnessesary.
RateX is offline
mrzonxino
Junior Member
Join Date: Sep 2014
Old 09-24-2014 , 09:03   Re: I need help fix code
Reply With Quote #5

No variable is 1 or 2
Example: he have 2000hp
After the first death he revial and now he have 2000 +500Hp
If he second death then he have 2500+500Hp

I think use
Quote:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>
#include <zombieplague>
#include <fakemeta>
#include <engine>
#include <fun>
#define PLUGIN "Respawn time level"
#define VERSION "1.0"
#define AUTHOR "mrzonxino"

new g_respawn_count[33]

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)

RegisterHam(Ham_Spawn, "player", "fw_PlayerRespawn", 1)
}

public fw_PlayerRespawn(id)
{
if zp_get_user_zombie(id)
return PLUGIN_CONTINUE;

set_task(1.0, "PlayerRespawn", id)
}

public PlayerRespawn(id)
{

if (g_respawn_count[id] = 1 ) // 1 = the first revival
{
set_user_health(id, get_user_health(id) + (500*1))
}
esle if (g_respawn_count[id] = 2 ) // 2 = second revival
{
set_user_health(id, get_user_health(id) + (500*2))
}
esle if (g_respawn_count[id] = X ) // X = X revival
{
set_user_health(id, get_user_health(id) + (500*X))
}

}

Last edited by mrzonxino; 09-24-2014 at 13:17.
mrzonxino is offline
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 09-25-2014 , 01:31   Re: I need help fix code
Reply With Quote #6

Sorry for the late reply. My network dropped to almost 1kbs yesterday
Quote:
Originally Posted by mrzonxino View Post
No variable is 1 or 2
g_respawn_count[id] is a variable, and you're checking if it is 1 or 2.
Here's the complete code(I added some additional funtions and checks so it could be reset at round start and upon connect):
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <zombieplague>
#include <fun>

#define PLUGIN "Respawn time level"
#define VERSION "1.0"
#define AUTHOR "mrzonxino"

new g_respawn_count[33]

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("HLTV""event_newround""a""1=0""2=0")
    
RegisterHam(Ham_Spawn"player""fw_PlayerRespawn"1)
}

public 
event_newround()
{
    new 
numiPlayers[32]
    
get_players(iPlayersnum)
    if( !
num )
    {
        return
    }
    for(new 
0numi++)
    {
        new 
id iPlayers[i]
        
g_respawn_count[id] = 0
    
}
}

public 
client_connect(id)
{
    
g_respawn_count[id] = 0
}

public 
client_disconnect(id)
{
    
g_respawn_count[id] = 0
}

public 
fw_PlayerRespawn(id

    if(!
zp_get_user_zombie(id))
        return
    
    
g_respawn_count[id]++
    if(
g_respawn_count[id] > 2g_respawn_count[id] = 
    set_task
(1.0"PlayerRespawn"id)
}

public 
PlayerRespawn(id)

    if(
g_respawn_count[id] == // 1 = the first revival
    
{
        
set_user_health(idget_user_health(id) + (500*1))
    }
    else if (
g_respawn_count[id] == // 2 = second revival
    
{
        
set_user_health(idget_user_health(id) + (500*2))
    }

Also, if you don't know how to make it, you can simply request for it. If you want to code, I sugguest you take a look at tutorials and already made plugins, 'cus it seems like you don't really know what you're doing

Last edited by RateX; 09-28-2014 at 10:49.
RateX is offline
mrzonxino
Junior Member
Join Date: Sep 2014
Old 09-25-2014 , 07:10   Re: I need help fix code
Reply With Quote #7

tks so much, i would learn hard. but plugin not running in zp 4.3 it is not add health zombie (only zombie, not use human)..You can fix plugin help me error this..

Last edited by mrzonxino; 09-25-2014 at 07:29.
mrzonxino is offline
Brian_Chino77
Senior Member
Join Date: Mar 2014
Location: dunno
Old 09-28-2014 , 09:56   Re: I need help fix code
Reply With Quote #8

Just add ..
Quote:
if (g_respawn_count[id] == 2 && zp_get_user_zombie(id))

Last edited by Brian_Chino77; 09-28-2014 at 09:59.
Brian_Chino77 is offline
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 09-28-2014 , 10:48   Re: I need help fix code
Reply With Quote #9

Quote:
Originally Posted by Brian_Chino77 View Post
Just add ..
Actually, the problem won't be solve that way. The reason is that I had a typo in zp_get_user_zombie(id). I have updated the code.
RateX is offline
mrzonxino
Junior Member
Join Date: Sep 2014
Old 09-29-2014 , 06:38   Re: I need help fix code
Reply With Quote #10

wao, very cool. Tks Rate so much i love U
mrzonxino is offline
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:29.


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