Thread: !beaconpls
View Single Post
Author Message
rodrigo286
Veteran Member
Join Date: Sep 2010
Location: Brazil, São Paulo
Old 04-16-2011 , 14:51   !beaconpls
Reply With Quote #1

Well, it's my first plugin, I would like to make a purchasing system beacon, where the player uses the !Beaconpls to buy a beacon for short time, but I am not knowing later add a function to give the player beacon.

PHP Code:
#include <sourcemod>
 
public Plugin:myinfo =
{
    
name "CZS beaconpls",
    
author "Rodrigo286, thanks to Mewtwo",
    
description "Command to buy a beacon.",
    
version "1.0.0.0",
    
url "http://www.sourcemod.net/"
};
 
public 
OnPluginStart()

)    

public 
BuyBeacon(client){
    new 
money;
    new 
cost;
    if (
g_iMoney == -1) return;
    if (
hasPara[client] == false){
        
money GetEntData(client,g_iMoney);
        
cost GetConVarInt(g_cost);
        if (
cost == 0){
            
PrintMsg(client,"Already have a beacon");
        }
        else{
            if((
money cost)<0){
                
PrintMsg(client,"No Money");
            }
            else{
                
hasPara[client] = true;
                
SetEntData(client,g_iMoney,money-cost);
                
PrintMsg(client,"Have Bought a beacon");
            }
        }
    }
    else{
        
PrintMsg(client,"Have beacon");
    }
    
}

public 
Action:HandleSay(clientargs){
    new 
String:line[30];
    if(
GetConVarInt(g_enabled) == 0) return Plugin_Continue;
    if (
args 0){
        
GetCmdArg(1,line,sizeof(line));
        if (
strcmp(g_game,"cstrike",false)==0){
            if (
StrEqual(line"!beaconpls"false) || StrEqual(line"!buy_beacon"false)) BuyBeacon(client);
        }
        else{
            
SetConVarInt(g_cost,0);
            if (
StrEqual(line"!beaconpls"false) || StrEqual(line"!buy_beacon"false)) PrintMsg(client,"Already have a beacon");
        }
    }
    return 
Plugin_Continue;

Regards.
rodrigo286 is offline