Taking CMDS in a gamemode and put it in a filterscript [Help]
#1

Hi i would like to take some cmds of a gamemode i have and put it in a filterscript but when im trying i get some errors but i have all the defines and includes needed. Can someone help me? thx
here the code
Код:
#include <a_samp>
#include <zcmd>
#include <sscanf>
#include <dudb>
#include <gvar>
#include <time>
#include <dprops>
#pragma unused strtok

cmd(startevent, playerid, params[])
{
	new string[120]; new pname[24]; GetPlayerName(playerid, pname, 24);
	if(GetPVarInt(playerid, "AdminLevel") == 0) return SendClientMessage(playerid, COLOR_ERROR, "Invalid Command. Read /commands.");
	if(GetPVarInt(playerid, "Jailed") == 1) return SendClientMessage(playerid, COLOR_ERROR, "You cannot use this command while in jail.");
	if(GetPVarInt(playerid, "Cuffed") == 1) return SendClientMessage(playerid, COLOR_ERROR, "You cannot use this command while cuffed.");
	new Float:x, Float:y, Float:z;
	GetPlayerPos(playerid, x, y, z);
	SetGVarFloat("EventX", x); SetGVarFloat("EventY", y); SetGVarFloat("EventZ", z); SetGVarInt("EventI", GetPlayerInterior(playerid)); SetGVarInt("EventStarted", 1);
	format(string, 120, "[ADMIN EVENT] Server Admin %s(%d) has started an event. Type /event to join.", pname, playerid);
	SendClientMessageToAll(COLOR_ADMIN, string);
	IRC_Say(gGroupID, IRC_CHANNEL, string);
	SendClientMessage(playerid, COLOR_GREEN, "You have started an event. Type /endevent to end it.");
	return 1;
}
cmd(event, playerid, params[])
{
	if(GetGVarInt("EventStarted") == 0) return SendClientMessage(playerid, COLOR_ERROR, "There's no event started.");
	SendClientMessage(playerid, COLOR_GREEN, "You have joined the Admin Event.");
	SetPlayerPos(playerid, GetGVarFloat("EventX"), GetGVarFloat("EventY"), GetGVarFloat("EventZ"));
	SetPlayerInterior(playerid, GetGVarInt("EventI"));
	SetPVarInt(playerid, "InEvent", 1);
	return 1;
}
cmd(endevent, playerid, params[])
{
	new pname[24]; new string[120]; GetPlayerName(playerid, pname, 24);
	if(GetPVarInt(playerid, "AdminLevel") == 0) return SendClientMessage(playerid, COLOR_ERROR, "Invalid Command. Read /commands");
	if(GetGVarInt("EventStarted") == 0) return SendClientMessage(playerid, COLOR_ERROR, "There's no event started.");
	SetGVarInt("EventStarted", 0);
	format(string, 120, "[ADMIN EVENT] Admin %s(%d) has ended the current event. You can no longer join.", pname, playerid);
	SendClientMessage(playerid, COLOR_ADMIN, string);
	return 1;
}
cmd(eventweapon, playerid, params[])
{
	new weapon; new ammo;
	if(GetPVarInt(playerid, "AdminLevel") == 0) return SendClientMessage(playerid, COLOR_ERROR, "Invalid Command.");
	//if(GetGVarInt("EventStarted") == 0) return SendClientMessage(playerid, COLOR_ERROR, "There's no event started.");
	if(sscanf(params, "ii", weapon, ammo)) return SendClientMessage(playerid, COLOR_ERROR, "Usage: /eventweapon (WeaponID) (Ammo)");
	for(new i = 0; i<MAX_PLAYERS; i ++)
	{
	    if(GetPVarInt(i, "InEvent") == 1)
	    {
	        GivePlayerWeapon(i, weapon, ammo);
	        SendClientMessage(i, COLOR_ADMIN, "You have been given an event weapon.");
	        SendClientMessage(playerid, COLOR_ADMIN, "You have given everyone at the event an event weapon.");
		}
	}
	return 1;
}
Reply
#2

Here is the filterscript im trying to compile
Код:
#define FILTERSCRIPT

#include <a_samp>
#include <zcmd>
#include <sscanf>
#include <dudb>
#include <gvar>
#include <time>
#include <dprops>

#pragma unused strtok

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print(" Event System");
	print("--------------------------------------\n");
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
cmd(startevent, playerid, params[])
{
	new string[120]; new pname[24]; GetPlayerName(playerid, pname, 24);
	if(GetPVarInt(playerid, "AdminLevel") == 0) return SendClientMessage(playerid, COLOR_ERROR, "Invalid Command. Read /commands.");
	new Float:x, Float:y, Float:z;
	GetPlayerPos(playerid, x, y, z);
	SetGVarFloat("EventX", x); SetGVarFloat("EventY", y); SetGVarFloat("EventZ", z); SetGVarInt("EventI", GetPlayerInterior(playerid)); SetGVarInt("EventStarted", 1);
	format(string, 120, "[ADMIN EVENT] Server Admin %s(%d) has started an event. Type /event to join.", pname, playerid);
	SendClientMessageToAll(COLOR_ADMIN, string);
	SendClientMessage(playerid, COLOR_GREEN, "You have started an event. Type /endevent to end it.");
	return 1;
}
cmd(event, playerid, params[])
{
	if(GetGVarInt("EventStarted") == 0) return SendClientMessage(playerid, COLOR_ERROR, "There's no event started.");
	SendClientMessage(playerid, COLOR_GREEN, "You have joined the Admin Event.");
	SetPlayerPos(playerid, GetGVarFloat("EventX"), GetGVarFloat("EventY"), GetGVarFloat("EventZ"));
	SetPlayerInterior(playerid, GetGVarInt("EventI"));
	SetPVarInt(playerid, "InEvent", 1);
	return 1;
}
cmd(endevent, playerid, params[])
{
	new pname[24]; new string[120]; GetPlayerName(playerid, pname, 24);
	if(GetPVarInt(playerid, "AdminLevel") == 0) return SendClientMessage(playerid, COLOR_ERROR, "Invalid Command. Read /commands");
	if(GetGVarInt("EventStarted") == 0) return SendClientMessage(playerid, COLOR_ERROR, "There's no event started.");
	SetGVarInt("EventStarted", 0);
	format(string, 120, "[ADMIN EVENT] Admin %s(%d) has ended the current event. You can no longer join.", pname, playerid);
	SendClientMessage(playerid, COLOR_ADMIN, string);
	return 1;
}
cmd(eventweapon, playerid, params[])
{
	new weapon; new ammo;
	if(GetPVarInt(playerid, "AdminLevel") == 0) return SendClientMessage(playerid, COLOR_ERROR, "Invalid Command.");
	//if(GetGVarInt("EventStarted") == 0) return SendClientMessage(playerid, COLOR_ERROR, "There's no event started.");
	if(sscanf(params, "ii", weapon, ammo)) return SendClientMessage(playerid, COLOR_ERROR, "Usage: /eventweapon (WeaponID) (Ammo)");
	for(new i = 0; i<MAX_PLAYERS; i ++)
	{
	    if(GetPVarInt(i, "InEvent") == 1)
	    {
	        GivePlayerWeapon(i, weapon, ammo);
	        SendClientMessage(i, COLOR_ADMIN, "You have been given an event weapon.");
	        SendClientMessage(playerid, COLOR_ADMIN, "You have given everyone at the event an event weapon.");
		}
	}
	return 1;
}
#endif
Errors :
Код:
C:\Users\Andrew\Desktop\EventSys5.pwn(27) : error 029: invalid expression, assumed zero
C:\Users\Andrew\Desktop\EventSys5.pwn(27) : error 017: undefined symbol "cmd_startevent"
C:\Users\Andrew\Desktop\EventSys5.pwn(27) : error 029: invalid expression, assumed zero
C:\Users\Andrew\Desktop\EventSys5.pwn(27) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#3

pawn Код:
/*
    Includes files.
    Located on your_server\pawno\include
*/

#include <a_samp>
#include <zcmd>
#include <sscanf>
#include <dudb>
#include <gvar>
#include <time>
#include <dprops>

#pragma unused strtok
/*
    OnFilterScriptInit() Callback.
*/

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Event System");
    print("--------------------------------------\n");
    return 1;
}
/*
    Commands with ZCMD
    * Note: Commands with ZCMD should be outside callbacks.
    Never use it with OnPlayerCommandText(playerid, cmdtext[]) callback.
    The result will be an error 029: invalid expression, assumed zero.
*/

cmd(startevent, playerid, params[])
{
    new string[120]; new pname[24]; GetPlayerName(playerid, pname, 24);
    if(GetPVarInt(playerid, "AdminLevel") == 0) return SendClientMessage(playerid, COLOR_ERROR, "Invalid Command. Read /commands.");
    if(GetPVarInt(playerid, "Jailed") == 1) return SendClientMessage(playerid, COLOR_ERROR, "You cannot use this command while in jail.");
    if(GetPVarInt(playerid, "Cuffed") == 1) return SendClientMessage(playerid, COLOR_ERROR, "You cannot use this command while cuffed.");
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    SetGVarFloat("EventX", x); SetGVarFloat("EventY", y); SetGVarFloat("EventZ", z); SetGVarInt("EventI", GetPlayerInterior(playerid)); SetGVarInt("EventStarted", 1);
    format(string, 120, "[ADMIN EVENT] Server Admin %s(%d) has started an event. Type /event to join.", pname, playerid);
    SendClientMessageToAll(COLOR_ADMIN, string);
    IRC_Say(gGroupID, IRC_CHANNEL, string);
    SendClientMessage(playerid, COLOR_GREEN, "You have started an event. Type /endevent to end it.");
    return 1;
}
cmd(event, playerid, params[])
{
    if(GetGVarInt("EventStarted") == 0) return SendClientMessage(playerid, COLOR_ERROR, "There's no event started.");
    SendClientMessage(playerid, COLOR_GREEN, "You have joined the Admin Event.");
    SetPlayerPos(playerid, GetGVarFloat("EventX"), GetGVarFloat("EventY"), GetGVarFloat("EventZ"));
    SetPlayerInterior(playerid, GetGVarInt("EventI"));
    SetPVarInt(playerid, "InEvent", 1);
    return 1;
}
cmd(endevent, playerid, params[])
{
    new pname[24]; new string[120]; GetPlayerName(playerid, pname, 24);
    if(GetPVarInt(playerid, "AdminLevel") == 0) return SendClientMessage(playerid, COLOR_ERROR, "Invalid Command. Read /commands");
    if(GetGVarInt("EventStarted") == 0) return SendClientMessage(playerid, COLOR_ERROR, "There's no event started.");
    SetGVarInt("EventStarted", 0);
    format(string, 120, "[ADMIN EVENT] Admin %s(%d) has ended the current event. You can no longer join.", pname, playerid);
    SendClientMessage(playerid, COLOR_ADMIN, string);
    return 1;
}
cmd(eventweapon, playerid, params[])
{
    new weapon; new ammo;
    if(GetPVarInt(playerid, "AdminLevel") == 0) return SendClientMessage(playerid, COLOR_ERROR, "Invalid Command.");
    //if(GetGVarInt("EventStarted") == 0) return SendClientMessage(playerid, COLOR_ERROR, "There's no event started.");
    if(sscanf(params, "ii", weapon, ammo)) return SendClientMessage(playerid, COLOR_ERROR, "Usage: /eventweapon (WeaponID) (Ammo)");
    for(new i = 0; i<MAX_PLAYERS; i ++)
    {
        if(GetPVarInt(i, "InEvent") == 1)
        {
            GivePlayerWeapon(i, weapon, ammo);
            SendClientMessage(i, COLOR_ADMIN, "You have been given an event weapon.");
            SendClientMessage(playerid, COLOR_ADMIN, "You have given everyone at the event an event weapon.");
        }
    }
    return 1;
}
Reply
#4

Working Thx alot!
Reply
#5

pawn Код:
/*
    Includes files.
    Located on your_server\pawno\include
*/

#include <a_samp>
#include <zcmd>
#include <sscanf>
#include <dudb>
#include <gvar>
#include <time>
#include <dprops>

#pragma unused strtok
/*
    OnFilterScriptInit() Callback.
*/

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Event System");
    print("--------------------------------------\n");
    return 1;
}
/*
    Commands with ZCMD
    * Note: Commands with ZCMD should be outside callbacks.
    Never use it with OnPlayerCommandText(playerid, cmdtext[]) callback.
    The result will be an error 029: invalid expression, assumed zero.
*/

CMD:startevent(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_ERROR, "You are not Admin!");
    /*
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_ERROR, "Message");
       
        * Note: ! means not. If someone isn't logged in as Rcon Administrator, he/she will get a message that he/she is not Admin!
        For Lux's Admin System it's:
       
        if(AccInfo[playerid][Level] < 3) return SendClientMessage(playerid, COLOR_ERROR, "Message");
       
        You can change the 3 to any level you want.
    */

    new
        string[120],
        pname[24];
    GetPlayerName(playerid, pname, 24);
    if(GetPVarInt(playerid, "AdminLevel") == 0) return SendClientMessage(playerid, COLOR_ERROR, "Invalid Command. Read /commands.");
    if(GetPVarInt(playerid, "Jailed") == 1) return SendClientMessage(playerid, COLOR_ERROR, "You cannot use this command while in jail.");
    if(GetPVarInt(playerid, "Cuffed") == 1) return SendClientMessage(playerid, COLOR_ERROR, "You cannot use this command while cuffed.");
    new
        Float:x,
        Float:y,
        Float:z;
    GetPlayerPos(playerid, x, y, z);
    SetGVarFloat("EventX", x); SetGVarFloat("EventY", y); SetGVarFloat("EventZ", z); SetGVarInt("EventI", GetPlayerInterior(playerid)); SetGVarInt("EventStarted", 1);
    format(string, 120, "[ADMIN EVENT] Server Admin %s(%d) has started an event. Type /event to join.", pname, playerid);
    SendClientMessageToAll(COLOR_ADMIN, string);
    IRC_Say(gGroupID, IRC_CHANNEL, string);
    SendClientMessage(playerid, COLOR_GREEN, "You have started an event. Type /endevent to end it.");
    return 1;
}
CMD:event(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_ERROR, "You are not Admin!");
    if(GetGVarInt("EventStarted") == 0) return SendClientMessage(playerid, COLOR_ERROR, "There's no event started.");
    SendClientMessage(playerid, COLOR_GREEN, "You have joined the Admin Event.");
    SetPlayerPos(playerid, GetGVarFloat("EventX"), GetGVarFloat("EventY"), GetGVarFloat("EventZ"));
    SetPlayerInterior(playerid, GetGVarInt("EventI"));
    SetPVarInt(playerid, "InEvent", 1);
    return 1;
}
CMD:endevent(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_ERROR, "You are not Admin!");
    new
        pname[24],
        string[120];
    GetPlayerName(playerid, pname, 24);
    if(GetPVarInt(playerid, "AdminLevel") == 0) return SendClientMessage(playerid, COLOR_ERROR, "Invalid Command. Read /commands");
    if(GetGVarInt("EventStarted") == 0) return SendClientMessage(playerid, COLOR_ERROR, "There's no event started.");
    SetGVarInt("EventStarted", 0);
    format(string, 120, "[ADMIN EVENT] Admin %s(%d) has ended the current event. You can no longer join.", pname, playerid);
    SendClientMessage(playerid, COLOR_ADMIN, string);
    return 1;
}
CMD:eventweapon(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_ERROR, "You are not Admin!");
    new
        weapon,
        ammo;
    if(GetPVarInt(playerid, "AdminLevel") == 0) return SendClientMessage(playerid, COLOR_ERROR, "Invalid Command.");
    //if(GetGVarInt("EventStarted") == 0) return SendClientMessage(playerid, COLOR_ERROR, "There's no event started.");
    if(sscanf(params, "ii", weapon, ammo)) return SendClientMessage(playerid, COLOR_ERROR, "Usage: /eventweapon (WeaponID) (Ammo)");
    for(new i = 0; i<MAX_PLAYERS; i ++) {
        if(GetPVarInt(i, "InEvent") == 1) {
            GivePlayerWeapon(i, weapon, ammo);
            SendClientMessage(i, COLOR_ADMIN, "You have been given an event weapon.");
            SendClientMessage(playerid, COLOR_ADMIN, "You have given everyone at the event an event weapon.");
        }
    }
    return 1;
}
/*
    However,
    CMD:command(playerid, params[]) is same as  cmd(command, playerid, params[]), but your way is older :P
    If you want change them back.
*/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)