AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Basic rules plugin (https://forums.alliedmods.net/showthread.php?t=105818)

OneMoreLevel 10-08-2009 17:28

Basic rules plugin
 
Hi, Im making a basic rules plugin, i know there are alot out there, hence im not going to publish it.
Although when I compile it, I get this:
Code:

Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

Error: Invalid expression, assumed zero on line 24
Warning: Expression has no effect on line 24
Error: Invalid expression, assumed zero on line 24
Warning: Expression has no effect on line 24
Error: Expected token: ";", but found ")" on line 24
Error: Too many error messages on one line on line 24

Compilation aborted.
4 Errors.
Could not locate output file C:\Program Files\AMX Mod X\amxxstudio\Untitled.amx (compile failed).

And my code is:
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define ADMIN_ALL0
#define PLUGIN "Jailbreak Rules"
#define VERSION "1.0"
#define AUTHOR "OneMoreLevel"
new const message [][] =
{
"If you typed /rules, and you see this, then the plug-in is working."
}
new const 
header [][] =
{
    
"Rules header"
}
public 
plugin_init() {
    
register_plugin("Rules""1.0""OneMoreLevel")
    
    
register_clcmd ("say /rules","jbrules","Show the rules")
}
public 
jbrules() {
    
    
show_motd 1, const message, const header 


I see nothing wrong with it, but me as being a newbie, of course there is.

Another bonus question: How can I make it so that when A person has a text file in the same folder as there motd.txt file is, and that file is named "rules.txt", it reads from that file to put it in the motd.

Any help would be greatly appreciated. :)

OneMoreLevel 10-08-2009 17:58

Re: Basic rules plugin
 
Nevermind guys, I got it working, my code so far is:

PHP Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Jailbreak Rules"
#define VERSION "1.0"
#define AUTHOR "OneMoreLevel"

new const message[] =
{
"here are the rules"
}
new const 
header[] =
{
"This is a header"
}

public 
plugin_init() {
    
register_plugin("Jailbreak Rules""1.0""OneMoreLevel")
    
    
register_clcmd ("say /rules""jbrules"0"Show the rules")
}
public 
jbrules(id)
{    
    
show_motd(idmessageheader


But I still have this question:
How can I make it so that when A person has a text file in the same folder as there motd.txt file is, and that file is named "rules.txt", it reads from that file to put it in the motd.

Nextra 10-08-2009 18:16

Re: Basic rules plugin
 
http://amxmodx.org/funcwiki.php?go=func&id=21

Quote:

message can either be a filename or a string formatted message. With VGUI2, the message can be HTML formatted.
So there's no problem in displaying a rules.txt. I'm not exactly sure whether you need to precache it, though.

/edit: This all happens serverside - just so you know. You can't display a file that exists on the client. To check wether rules.txt exists on the server use file_exists( file[] )

izzle 10-08-2009 20:27

Re: Basic rules plugin
 
Quote:

Originally Posted by OneMoreLevel (Post 956165)
Nevermind guys, I got it working, my code so far is:But I still have this question:
How can I make it so that when A person has a text file in the same folder as there motd.txt file is, and that file is named "rules.txt", it reads from that file to put it in the motd.

You can do it like this

PHP Code:

#include <amxmodx>
#include <amxmisc>


public plugin_init() {
    
register_plugin("JailBreakRules""1.0""izzle");
    
    
register_clcmd("say /rules""JailBreakRules"0"JailBreakRules");
}


public 
JailBreakRules(id) {
    
show_motd(id"rules.txt""JailBreakRules");
    return 
PLUGIN_HANDLED;



OneMoreLevel 10-08-2009 20:43

Re: Basic rules plugin
 
thank you, I figured it out before, but thanks for the reply :D

izzle 10-08-2009 20:46

Re: Basic rules plugin
 
:)


All times are GMT -4. The time now is 22:33.

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