AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   !beaconpls (https://forums.alliedmods.net/showthread.php?t=155026)

rodrigo286 04-16-2011 14:51

!beaconpls
 
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.

databomb 04-16-2011 16:08

Re: !beaconpls
 
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)


All times are GMT -4. The time now is 14:50.

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