AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help With Script (https://forums.alliedmods.net/showthread.php?t=133574)

codyscafe7 07-26-2010 19:11

Help With Script
 
Hey im making a script.

Here is what I have, I know something must be wrong but I can't figure out what i've done incorrectly, thanks.

Code:

#include <amxmodx>
#include <cstrike>
#include <engine>
#include <amxmisc>
#include <fakemeta_util>
#include <fun>
#include <xs>

#define PLUGIN    "Buyxp"
#define VERSION    "1.0"
#define AUTHOR    "codyscafe7"

new xpcost[1] = {10000}

/* Initialization */

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_clcmd("say buyxp", "cmd_buyxp", 0, "- Buy Experience!")
    register_cvar("buyxp", "30")
}


public cmd_buyxp(id)
{
    new usermoney = cs_get_user_money(id)
//    new username = get_user_name(id)
    if (usermoney<xpcost){
        client_print(id,print_center,"Your too poor for this. It's 10000!")
        return PLUGIN_HANDLED
    }
    else if cs_set_user_money(id,usermoney-xpcost,1)
            server_cmd ("pm_givexp ^"name^" @1", 30")
            return PLUGIN_HANDLED
}


RedRobster 07-26-2010 19:21

Re: Help With Script
 
Change
PHP Code:

new xpcost[1] = (10000

to
PHP Code:

new xpcost 10000 

And.
PHP Code:

public cmd_buyxp(id) {     new usermoney cs_get_user_money(id//    new username = get_user_name(id)     if (usermoney<xpcost){         client_print(id,print_center,"Your too poor for this. It's 10000!")         return PLUGIN_HANDLED     }     else if cs_set_user_money(id,usermoney-xpcost,1)             server_cmd ("pm_givexp ^"name^" @1", 30")             return PLUGIN_HANDLED } 

You need to put brackets for the second if condition.

Devil259 07-26-2010 19:29

Re: Help With Script
 
PHP Code:

new xpcost 10000
 
new pcvarXp
 
public plugin_init()
{
    
register_clcmd("say buyxp""cmd_buyxp"0"- Buy Experience!")
    
pcvarXp register_cvar("buyxp""30")
}
 
public 
cmd_buyxp(id)
{
    new 
usermoney cs_get_user_money(id)
    new 
name[32]
 
    
get_user_name(idname31)
 
    if ( 
usermoney xpcost )
    {
        
client_print(id,print_center,"You're too poor for this. It's %d!"xpcost)
        return 
PLUGIN_HANDLED
    
}
 
    else
    {
        
cs_set_user_money(idusermoney xpcost ,1)
        
server_cmd ("pm_givexp ^"%s^" %d"nameget_pcvar_num pcvarXp ) )
        return 
PLUGIN_HANDLED
    



Look and replace if it's false.

RedRobster 07-26-2010 19:36

Re: Help With Script
 
What you posted will not work either. You are defining XPCOST as a string, not as a variable.

Devil259 07-26-2010 19:40

Re: Help With Script
 
Edited, don't see that you have posted. :mrgreen:

RedRobster 07-26-2010 19:42

Re: Help With Script
 
Quote:

Originally Posted by Devil259 (Post 1252547)
Edited, don't see that you have posted. :mrgreen:

:)

I missed some stuff that you found, so it's probably a good thing you did.

codyscafe7 07-26-2010 19:46

Re: Help With Script
 
I'm still getting:
error 001: expected token: "<", but found "-identifier-"
error 037: invalid string "possibly non-terminating script"


thanks for help.

RedRobster 07-26-2010 20:02

Re: Help With Script
 
PHP Code:

#include <amxmodx>
#include <cstrike>

new xpcost 10000
 
new pcvarXp
 
public plugin_init()
{
    
register_clcmd("say buyxp""cmd_buyxp"0"- Buy Experience!")
    
pcvarXp register_cvar("buyxp""30")
}
 
public 
cmd_buyxp(id)
{
    new 
usermoney cs_get_user_money(id)
    
    new 
name[32]
    
get_user_name(idname31)
 
    if ( 
usermoney xpcost )
    {
        
client_print(id,print_center,"You're too poor for this. It's %d!"xpcost)
    }
    else
    {
        
cs_set_user_money(idusermoney xpcost ,1)
        
server_cmd ("pm_givexp ^"%s^" ^"@1^" ^"%i^""nameget_pcvar_num pcvarXp ) )
    }
    
    return 
PLUGIN_HANDLED




All times are GMT -4. The time now is 00:06.

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