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

!beaconpls


Post New Thread Reply   
 
Thread Tools Display Modes
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
databomb
Veteran Member
Join Date: Jun 2009
Location: california
Old 04-16-2011 , 16:08   Re: !beaconpls
Reply With Quote #2

I won't pick apart each line yet since you're not done. Some things you should consider adding:

A repeatable timer that starts OnMapStart and goes till the map ends

A global boolean array of size MAXPLAYERS+1 to tell if someone has bought a beacon

A way to get rid of beacons (likely avenues: map end, or hook the player_death event)
__________________
databomb 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 07:01.


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