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

Noob requesting help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Jc Dock
New Member
Join Date: Mar 2014
Old 03-04-2014 , 09:25   Noob requesting help
Reply With Quote #1

I have recently decided to give making Sourcemod plugins a go so I have been following a youtube series on it but I have ran into a problem. The code is meant to take an input from the player, store it in an array and then recall the number when the player requests it. I copied exactly what was happening in the tutorial but for some reason when I go to compile it throws errors
The Code:
Code:
#include <sourcemod>

new Items[32];

public Plugin:myinfo = {
name = "Array Tutorial",
author = "me",
description = "Derp",
url = "http://youtube.com"
};

public OnPluginStart()
{
    RegConsoleCmd("sm_setnum", CommandSetNum, "");
    RegConsoleCmd("sm_getnum", CommandGetNum, "");
}

Public OnClientPutInServer(client)
{
    Items[client] = -1;
}

Public Action:CommandSetNum(client, args)
{
    if(args < 1)
    {
        PrintToChat(client, "Please Enter a Number!");
        return Plugin_Handled 
    }
    
    new String:arg1[3], arg1int;
    
    GetCmdArg(1, arg1, sizeof(arg1));
    
    arg1int = StringToInt(arg1);

    if (arg1int < 0) return Plugin_Handled; //Checking for neg numbers
    
    Items[client] = arg1int;
    
    PrintToChat(client, "Number: %d has been stored!", Items[client]);
    
    return Plugin_Handled; 
}

Public Action:CommandGetNum(client, args)
{
    if(Items[client] < 0)
    {
        PrintToChat(client, "Please Enter a Number!");
        return Plugin_Handled;
    } else {
        PrintToChat(client, "Your saved number is: %d", Items[client]);
        return Plugin_Handled;
    }
}
The Errors:
Code:
// C:\srcds\CSS\cstrike\addons\sourcemod\scripting\jc_array.sp(54) : error 010:
invalid function or declaration
// C:\srcds\CSS\cstrike\addons\sourcemod\scripting\jc_array.sp(3) : warning 203:
 symbol is never used: "Items"
// C:\srcds\CSS\cstrike\addons\sourcemod\scripting\jc_array.sp(31) : warning 203
: symbol is never used: "arg1"
// C:\srcds\CSS\cstrike\addons\sourcemod\scripting\jc_array.sp(31) : warning 203
: symbol is never used: "arg1int"
//
// 17 Errors.
//
// Compilation Time: 0.06 sec
// ----------------------------------------

Press enter to exit ...
If someone could explain what's wrong with the code I would really appreciate it.
Jc Dock is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 03-04-2014 , 10:10   Re: Noob requesting help
Reply With Quote #2

If you were to use c++ or anything similar like that you would have noticed that you put "Public" and not "public" coding is case sensitive.
PHP Code:
#include <sourcemod>

new Items[MAXPLAYERS+1] = {-1,...};

public 
Plugin:myinfo = {
    
name "Array Tutorial",
    
author "me",
    
description "Derp",
    
url "http://youtube.com"
};

public 
OnPluginStart()
{
    
RegConsoleCmd("sm_setnum"CommandSetNum"");
    
RegConsoleCmd("sm_getnum"CommandGetNum"");
}

public 
OnClientPutInServer(client)
{
    
Items[client] = -1;
}

public 
Action:CommandSetNum(clientargs)
{
    if(
args 1)
    {
        
PrintToChat(client"Please Enter a Number!");
        return 
Plugin_Handled 
    
}

    new 
String:arg1[3], arg1int;

    
GetCmdArg(1arg1sizeof(arg1));

    
arg1int StringToInt(arg1);

    if (
arg1int 0
    {
        return 
Plugin_Handled//Checking for neg numbers
    
}

    
Items[client] = arg1int;

    
PrintToChat(client"Number: %d has been stored!"Items[client]);

    return 
Plugin_Handled
}

public 
Action:CommandGetNum(clientargs)
{
    if(
Items[client] < 0)
    {
        
PrintToChat(client"Please Enter a Number!");
        return 
Plugin_Handled;
    }
    
PrintToChat(client"Your saved number is: %d"Items[client]);
    return 
Plugin_Handled;


Last edited by Mitchell; 03-04-2014 at 10:10.
Mitchell is offline
Jc Dock
New Member
Join Date: Mar 2014
Old 03-04-2014 , 10:53   Re: Noob requesting help
Reply With Quote #3

Quote:
Originally Posted by Mitchell View Post
If you were to use c++ or anything similar like that you would have noticed that you put "Public" and not "public" coding is case sensitive.
PHP Code:
#include <sourcemod>

new Items[MAXPLAYERS+1] = {-1,...};

public 
Plugin:myinfo = {
    
name "Array Tutorial",
    
author "me",
    
description "Derp",
    
url "http://youtube.com"
};

public 
OnPluginStart()
{
    
RegConsoleCmd("sm_setnum"CommandSetNum"");
    
RegConsoleCmd("sm_getnum"CommandGetNum"");
}

public 
OnClientPutInServer(client)
{
    
Items[client] = -1;
}

public 
Action:CommandSetNum(clientargs)
{
    if(
args 1)
    {
        
PrintToChat(client"Please Enter a Number!");
        return 
Plugin_Handled 
    
}

    new 
String:arg1[3], arg1int;

    
GetCmdArg(1arg1sizeof(arg1));

    
arg1int StringToInt(arg1);

    if (
arg1int 0
    {
        return 
Plugin_Handled//Checking for neg numbers
    
}

    
Items[client] = arg1int;

    
PrintToChat(client"Number: %d has been stored!"Items[client]);

    return 
Plugin_Handled
}

public 
Action:CommandGetNum(clientargs)
{
    if(
Items[client] < 0)
    {
        
PrintToChat(client"Please Enter a Number!");
        return 
Plugin_Handled;
    }
    
PrintToChat(client"Your saved number is: %d"Items[client]);
    return 
Plugin_Handled;

I had the feeling it would be something soo simple like that... guess that's what I get for coding at 3am!

Thanks so much for your help
Jc Dock is offline
Reply



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 16:24.


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