AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   T-Virus Antidote (https://forums.alliedmods.net/showthread.php?t=92006)

Emilioneri 05-08-2009 17:29

T-Virus Antidote
 
PHP Code:

/* Plugin generated by Emilioneri */

#include <amxmodx>
#include <amxmisc>
#include <biohazard>
#include <cstrike>

#define PLUGIN "T-Virus Antidote"
#define VERSION "1.0"
#define AUTHOR "Emilioneri"

new g_Cost


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
// Add your code here...
    
g_Cost register_cvar("amx_antidotecost""5000")
    
register_clcmd("say /antidote""cmd_antidote")
    
register_logevent("Event_Round_Start"2"1=Round_Start")
}

public 
Event_Round_Start()
{
    
client_print(0print_chat"To buy an Antidote type in chat: /antidote")
}

public 
cmd_antidote(id)
{       
    if(!
is_user_alive(id))
    {
        
client_print(idprint_chat"You can't buy an antidote while you are dead!")
    }
    
    if(!
is_user_zombie(id))
    {
        
client_print(idprint_chat"You can't buy an antidote, because you are a human")
    }
    
    new 
iMoney cs_get_user_money(id)
    new 
iCost get_pcvar_num(g_Cost)
    
    if(
iMoney >= iCost)
    {
        
cs_set_user_money(idiMoney iCost)
        
cure_user(id)
        
client_print(idprint_chat"You have used an antidote")
    }
    else
    {
        
client_print(idprint_chat"You don't have enaugh moeny! $%i needed!"iCost)
    }


I've got 2 questions:
1. Why this code doesn't work :?:
2. Why is "cs_get_user_money" useless :?: And what way Biohazard uses to set money :?:
3. +k who will help me!

anakin_cstrike 05-09-2009 07:53

Re: T-Virus Antidote
 
You have to return a value in that if statement. If you do that, the rest of the code won't be executed.

Code:

if(!is_user_alive(id))
    {
       
client_print(id, print_chat, "You can't buy an antidote while you are dead!");
        return PLUGIN_HANDLED;
    }




Biohazard uses fakemeta to retreive & set a player's amount of money. Cstrike is faster than fm, so your method is fine.


Emilioneri 05-09-2009 12:06

Re: T-Virus Antidote
 
so, this code will work :?:
PHP Code:

/* Plugin generated by Emilioneri */

#include <amxmodx>
#include <amxmisc>
#include <biohazard>
#include <cstrike>

#define PLUGIN "T-Virus Antidote"
#define VERSION "1.0"
#define AUTHOR "Emilioneri"

new g_Cost


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
// Add your code here...
    
g_Cost register_cvar("amx_antidotecost""5000")
    
register_clcmd("say /antidote""cmd_antidote")
    
register_logevent("Event_Round_Start"2"1=Round_Start")
}

public 
Event_Round_Start()
{
    
client_print(0print_chat"To buy an Antidote type in chat: /antidote")
}

public 
cmd_antidote(id)
{       
    if(!
is_user_alive(id))
    {
        
client_print(idprint_chat"You can't buy an antidote while you are dead!");
        return 
PLUGIN_HANDLED;
    }
    
    if(!
is_user_zombie(id))
    {
        
client_print(idprint_chat"You can't buy an antidote, because you are a human");
        return 
PLUGIN_HANDLED;
    }
    
    new 
iMoney cs_get_user_money(id)
    new 
iCost get_pcvar_num(g_Cost)
    
    if(
iMoney >= iCost)
    {
        
cs_set_user_money(idiMoney iCost)
        
cure_user(id)
        
client_print(idprint_chat"You have used an antidote");
        return 
PLUGIN_HANDLED;
    }
    else
    {
        
client_print(idprint_chat"You don't have enaugh moeny! $%i needed!"iCost)
    }
    return 
PLUGIN_HANDLED;



anakin_cstrike 05-09-2009 13:27

Re: T-Virus Antidote
 
The best way to know that, is testing it. Should work tough.

Emilioneri 05-09-2009 13:53

Re: T-Virus Antidote
 
I can't test it cuz I don't have a biohazard server :mrgreen: :mrgreen: :mrgreen: :mrgreen:

crazyeffect 05-09-2009 13:55

Re: T-Virus Antidote
 
Too lazy now...

Ask Mando128

Hunter-Digital 05-09-2009 13:59

Re: T-Virus Antidote
 
Quote:

Originally Posted by Emilioneri (Post 824261)
I can't test it cuz I don't have a biohazard server :mrgreen: :mrgreen: :mrgreen: :mrgreen:

make one :} listen + bots or something :P

TitANious 05-09-2009 14:01

Re: T-Virus Antidote
 
Bots dont work on them :) They are to stupid

Emilioneri 05-09-2009 14:05

Re: T-Virus Antidote
 
Quote:

Originally Posted by TitANious (Post 824271)
Bots dont work on them :) They are to stupid

Yeah, they are shooting at their teamates and zombie is trying to kill another zombie :mrgreen::mrgreen::mrgreen:

Hunter-Digital 05-09-2009 14:11

Re: T-Virus Antidote
 
bots rulz :crab:

:lol: anyway, then... make a dedicated one, and ask a friend to help you out :)


All times are GMT -4. The time now is 01:31.

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