/announce command with ZCMD -.-
#1

I am pretty new on scripting, and learning commands with ZMCD.
I have failed my command after a lot of different attempts, and if someone could help me with fixing it I'd really appreciate it!

So, I get these errors;
Quote:

G:\Documents and Settings\Administrator\Desktop\Gta Scripting\DM test\gamemodes\test.pwn(283) : error 035: argument type mismatch (argument 2)
G:\Documents and Settings\Administrator\Desktop\Gta Scripting\DM test\gamemodes\test.pwn(287) : error 035: argument type mismatch (argument 2)
G:\Documents and Settings\Administrator\Desktop\Gta Scripting\DM test\gamemodes\test.pwn(289) : error 035: argument type mismatch (argument 2)
G:\Documents and Settings\Administrator\Desktop\Gta Scripting\DM test\gamemodes\test.pwn(291) : error 035: argument type mismatch (argument 2)
G:\Documents and Settings\Administrator\Desktop\Gta Scripting\DM test\gamemodes\test.pwn(292) : warning 209: function "cmd_announce" should return a value
G:\Documents and Settings\Administrator\Desktop\Gta Scripting\DM test\gamemodes\test.pwn(293) : error 010: invalid function or declaration
G:\Documents and Settings\Administrator\Desktop\Gta Scripting\DM test\gamemodes\test.pwn(294) : error 010: invalid function or declaration

And this is a code..

pawn Код:
COMMAND:announce(playerid, params[])
{
    if(!IsPlayerAdmin(playerid))
    {
        new text[64], time, style;
        if (sscanf(params, "iis[64]", style, time, text))
            {
                if (strlen(text) > 64)
                {
                     if(style == 2)
                     {
                        if (style < 0 || style > 6)
                        {
                            if (time > 20*1000)
                            GameTextForAll(text, time, style);
                            }
                            else return SendClientMessage(playerid,"No longer than 20 seconds");
                        }
                        else return SendClientMessage(playerid,0x854900FF,"Invalid style");
                     }
                    else return SendClientMessage(playerid,"Bug with style 2! Do not use it!");
                }
                else return SendClientMessage(playerid,"Message too long, please make it with less than 64 letters!");
            }
            else return SendClientMessage(playerid,"Usage: /announce <style[0-6]> <time in ms> <text>");
    }
    else return SendClientMessage(playerid,''Only RCON Adminstrator can use this!''
    return 1;
}
What is wrong with it?
Reply
#2

Missing bracket:

pawn Код:
COMMAND:announce(playerid, params[])
{
    if(!IsPlayerAdmin(playerid))
    {
        new text[64], time, style;
        if (sscanf(params, "iis[64]", style, time, text))
       
            {
                if (strlen(text) > 64)
                {
                     if(style == 2)
                     {
                        if (style < 0 || style > 6)
                        {
                            if (time > 20*1000) {
                            GameTextForAll(text, time, style);
                            }
                            else return SendClientMessage(playerid,"No longer than 20 seconds");
                        }
                        else return SendClientMessage(playerid,0x854900FF,"Invalid style");
                     }
                    else return SendClientMessage(playerid,"Bug with style 2! Do not use it!");
                }
                else return SendClientMessage(playerid,"Message too long, please make it with less than 64 letters!");
            }
            else return SendClientMessage(playerid,"Usage: /announce <style[0-6]> <time in ms> <text>");
    }
    else return SendClientMessage(playerid,''Only RCON Adminstrator can use this!''
    return 1;
}
Reply
#3

With your code I got more warnings:
pawn Код:
G:\Documents and Settings\Administrator\Desktop\Gta Scripting\DM test\gamemodes\test.pwn(294) : error 027: invalid character constant
G:\Documents and Settings\Administrator\Desktop\Gta Scripting\DM test\gamemodes\test.pwn(294) : error 017: undefined symbol "Only"
G:\Documents and Settings\Administrator\Desktop\Gta Scripting\DM test\gamemodes\test.pwn(294) : error 017: undefined symbol "RCON"
And the old ones keeps staying too.
Reply
#4

Your fogot the color on sendclientmessage.
pawn Код:
COMMAND:announce(playerid, params[])
{
    new text[64], time, style;
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR,"Only RCON Adminstrator can use this!");
    else if (sscanf(params, "iis[64]", style, time, text)) return SendClientMessage(playerid,COLOR,"Usage: /announce <style[0-6]> <time in ms> <text>");
    else if (strlen(text) > 64) return SendClientMessage(playerid,COLOR,"Message too long, please make it with less than 64 letters!");
    else if (style == 2) return SendClientMessage(playerid,COLOR,"Bug with style 2! Do not use it!");
    else if (style < 0 || style > 6) return SendClientMessage(playerid,0x854900FF,"Invalid style");
    else if (time > 20*1000) return SendClientMessage(playerid, COLOR,"No longer than 20 seconds");
    else {
        GameTextForAll(text, time, style);
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by Kostas'
Посмотреть сообщение
Your fogot the color on sendclientmessage.
pawn Код:
COMMAND:announce(playerid, params[])
{
    new text[64], time, style;
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR,"Only RCON Adminstrator can use this!");
    else if (sscanf(params, "iis[64]", style, time, text)) return SendClientMessage(playerid,COLOR,"Usage: /announce <style[0-6]> <time in ms> <text>");
    else if (strlen(text) > 64) return SendClientMessage(playerid,COLOR,"Message too long, please make it with less than 64 letters!");
    else if (style == 2) return SendClientMessage(playerid,COLOR,"Bug with style 2! Do not use it!");
    else if (style < 0 || style > 6) return SendClientMessage(playerid,0x854900FF,"Invalid style");
    else if (time > 20*1000) return SendClientMessage(playerid, COLOR,"No longer than 20 seconds");
    else {
        GameTextForAll(text, time, style);
    }
    return 1;
}
When I put these it says they are Undefined Symbol if I compile..
Reply
#6

It compiles fine for me, I tested.
Make sure, you didn't add it inside any callback. or that you are using
pawn Код:
#include <zcmd>
#include <sscanf2>
Reply
#7

Quote:
Originally Posted by Armqus_FIN
Посмотреть сообщение
When I put these it says they are Undefined Symbol if I compile..
if you dont have the color defined.. of course it will say that..
replace COLOR with ' -1 '
eg
SendClientMessage(playerid,-1,"hi, how are you?");
Reply
#8

For colours you need to use hexadecimal expression.

Like this 0xE01B4CFF

You need to go on this site: http://www.colorpicker.com/ Pick some colour and that add 0x before and FF after that code
Reply
#9

Quote:
Originally Posted by Kostas'
Посмотреть сообщение
It compiles fine for me, I tested.
Make sure, you didn't add it inside any callback. or that you are using
pawn Код:
#include <zcmd>
#include <sscanf2>
Please put your FULL code, that worked fine to pastebin please
Because I keep getting errors still.
Reply
#10

Show me the errors please to fix it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)