SA-MP Forums Archive
strcmp - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: strcmp (/showthread.php?tid=429647)



strcmp - NathNathii - 10.04.2013

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?


Re: strcmp - Scenario - 10.04.2013

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?


Re: strcmp - NathNathii - 10.04.2013

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


Re: strcmp - DetoNater - 10.04.2013

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;
}



Re: strcmp - NathNathii - 10.04.2013

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

--Same errors.


Re: strcmp - Scenario - 10.04.2013

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.


Re: strcmp - DetoNater - 10.04.2013

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.


Re: strcmp - NathNathii - 10.04.2013

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



Re: strcmp - Scenario - 10.04.2013

You didn't include ZCMD.


Re: strcmp - NathNathii - 10.04.2013

pawn Код:
#include <zcmd>