Raised This Month: $ Target: $400
 0% 

plugin wait for command complete


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xxxperts
Senior Member
Join Date: Oct 2013
Location: India
Old 11-24-2013 , 09:06   plugin wait for command complete
Reply With Quote #1

i had created a plugin that give hp to player to whom u are spectating by typing "pray" but i had one problem when i say pray to targets if i change my spectating user than plugin also change the target and it give the health to targets2.!!!

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <ColorChat>
#include <fun>

#define PLUGIN "Pray Plugin"
#define VERSION "1.0"
#define AUTHOR "XxXPeRtS"

#define PREFIX "[ZOF 'X]"

new targets_hp
new nHp_max
new health_max
new bool:prayed[33];
new 
pcvar_hp;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_clcmd("say pray""cmd_GiveHp");
    
register_clcmd("pray""cmd_GiveHp");
    
    
health_max register_cvar("target_max_hp""100")
    
pcvar_hp register_cvar("amx_pray_hp""20");
    
    
register_event("HLTV""event_NewRound""a""1=0""2=0");
}

public 
event_NewRound()
{
    for(new 
i=133i++)
    {
        
prayed[i] = false;
    }
}

public 
client_putinserver(id)
{
    
prayed[id] = false;
}

public 
cmd_GiveHp(id)
{
    new 
iSpecMode entity_get_int(idEV_INT_iuser1);
    new 
player entity_get_int(idEV_INT_iuser2);
    
    new 
name2[32], name[32];
    
get_user_name(playername2charsmax(name2));
    
get_user_name(idnamecharsmax(name));
    
    if(
is_user_alive(id))
    {
        
ColorChat(idGREEN"%s ^x01Play or ^x03Pray For Players..xD.!!"PREFIX);
        return 
PLUGIN_CONTINUE;
    }

    if(
prayed[id])
    {
        
ColorChat(idGREEN"%s ^x01You Had Already ^x03Prayed This Round..!!"PREFIX);
        return 
PLUGIN_CONTINUE;
    }
    
    if(
iSpecMode == || iSpecMode == 3)
    {
        
ColorChat(idGREEN"%s ^x01You are not a ^x03Spectating a player.!!"PREFIX);
        return 
PLUGIN_CONTINUE;
    }
    else
    {
        
ColorChat(0GREEN"%s ^x03%s ^x04Has Just Prayed For ^x03%s"PREFIXnamename2);
        
set_task(2.50"Praying"id);
    }
    return 
PLUGIN_CONTINUE;
}

public 
Praying(id)
{
    new 
iSpec entity_get_int(idEV_INT_iuser2);
    new 
player entity_get_int(idEV_INT_iuser2);
    
    new 
name2[32], name[32];
    
get_user_name(playername2charsmax(name2));
    
get_user_name(idnamecharsmax(name));
    
    
nHp_max get_pcvar_num (health_max);
    
targets_hp get_user_health(player);
    
nHp_max get_pcvar_num (health_max);
    
    if(
targets_hp == nHp_max)
    {
        
ColorChat(idGREEN"%s ^x01Praying Failed. ^x03%s Already Has 100HP ^x04 Please Pray Some Else.!!"PREFIXname2);
        return 
PLUGIN_CONTINUE;
    }
    
    if(!
is_user_alive(player))
    {
        
ColorChat(idGREEN"%s ^x01 Aww.! %s Has Died Before Your Prayer Was Completed..!"PREFIXname2)
        
prayed[id] = true;
        return 
PLUGIN_CONTINUE;
    }
    
    
set_user_health(iSpecmin((get_user_health(iSpec)+get_pcvar_num(pcvar_hp)), 100))
    
prayed[id] = true;
    return 
PLUGIN_HANDLED;


Last edited by xxxperts; 11-24-2013 at 09:08.
xxxperts 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 14:06.


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