strcmp
#1

I did use zcmd before, but now I'm trying to learn strcmp, so I wanted to convert this to strcmp
pawn Код:
CMD:cc(playerid, params[])
{
 if(APlayerData[playerid][PlayerLevel] >= 1 || IsPlayerAdmin(playerid))
 {
 for(new i = 0; i < 100; i++)
 {
 SendClientMessageToAll(-1, " ");
 }
 SendClientMessageToAll(0x0079F2FF,"Chat Cleared!");
 }
 return 1;
}
And I got it like this (dont know if it is right)
pawn Код:
if(strcmp("/cc",cmdtext,true,3) == 0)
    {
    if(!IsPlayerAdmin(playerid))
    {
    for(new i = 0; i < 100; i++)
    {
    SendClientMessageToAll(-1, " ");
    }
    SendClientMessageToAll(0x0079F2FF,"Chat Cleared!");
    }
    return 1;
}
And I get 4 errors.
Код:
C:\Users\Documents\Gamemode Testing\gamemodes\Gamemode.pwn(480) : error 010: invalid function or declaration
C:\Users\Documents\Gamemode Testing\gamemodes\Gamemode.pwn(482) : error 010: invalid function or declaration
C:\Users\Documents\Gamemode Testing\gamemodes\Gamemode.pwn(484) : error 010: invalid function or declaration
C:\Users\Documents\Gamemode Testing\gamemodes\Gamemode.pwn(490) : error 010: invalid function or declaration
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Could anyone tell me what I did wrong, since I am new into this?
Reply
#2

Mate, you do realize strcmp is MUCH slower than ZCMD for command processing? Why on Earth would you want to switch to something that's slower?
Reply
#3

I'm helping my friend with something at he's gamemode and he is using strcmp /:
Reply
#4

Exactly as RealCop said ZCMD is faster in cmd processing...

try this....
pawn Код:
if(strcmp("/cc",cmdtext,true,3) == 0)
{
    if(!IsPlayerAdmin(playerid))
    {
    for(new i = 0; i < 100; i++)
    SendClientMessageToAll(-1, " ");
    SendClientMessageToAll(0x0079F2FF,"Chat Cleared!");
    }
    return 1;
}
Reply
#5

May be true, but he/i dont know how to change it to zcmd when the whole script is strcmp.

--Same errors.
Reply
#6

Well, if he doesn't have many commands, you should recommend switching.

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/cc", true)) // no reason to specify a length parameter here IMHO
    {
        if(IsPlayerAdmin(playerid)) // you need to check IF they are an admin, so IsPlayerAdmin() and NOT !IsPlayerAdmin
        {
            for(new i = 0; i < 100; i++) SendClientMessageToAll(-1, " "); // no reason for braces surrounding a single piece of code
            SendClientMessageToAll(0x0079F2FF,"Chat Cleared!");
        }
        return 1; // have to return 1 at the end of commands using OnPlayerCommandText
    }
    return 0; // OnPlayerCommandText returns 0 at the end, not 1.
}
You had a few things messed up, and you were missing a brace.
Reply
#7

Quote:
Originally Posted by NathNathii
Посмотреть сообщение
May be true, but he/i dont know how to change it to zcmd when the whole script is strcmp.

--Same errors.
Just follow this
pawn Код:
#include <zcmd>

CMD:cc(playerid, params[])
{
    if(!IsPlayerAdmin(playerid))
    {
    for(new i = 0; i < 100; i++)
    SendClientMessageToAll(-1, " ");
    SendClientMessageToAll(0x0079F2FF,"Chat Cleared!");
    }
    return 1;
}
//download zcmd.inc if you dont have.
Reply
#8

Fixed to zcmd, now i get these

Код:
C:\Users\Documents\LVCnR Testing\gamemodes\Gamemode.pwn(471) : error 029: invalid expression, assumed zero
C:\Users\Documents\LVCnR Testing\gamemodes\Gamemode.pwn(471) : error 017: undefined symbol "cmd_test"
C:\Users\Documents\LVCnR Testing\gamemodes\Gamemode.pwn(471) : error 029: invalid expression, assumed zero
C:\Users\Documents\LVCnR Testing\gamemodes\Gamemode.pwn(471) : fatal error 107: too many error messages on one line
Reply
#9

You didn't include ZCMD.
Reply
#10

pawn Код:
#include <zcmd>
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)