SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 26/05/2019, 11:53 AM   #1
Edvukas
Little Clucker
 
Join Date: Nov 2018
Posts: 18
Reputation: 0
Default Need help with // command

Hello, how can I make command // where I can chat with other? I have command with strcmp but I need better variant
Edvukas is offline   Reply With Quote
Old 26/05/2019, 12:07 PM   #2
OtimoJogo
Big Clucker
 
Join Date: Jul 2016
Posts: 160
Reputation: 2
Default Re: Need help with // command

Could you post your command? That way we can improve on it.
OtimoJogo is offline   Reply With Quote
Old 26/05/2019, 12:15 PM   #3
Edvukas
Little Clucker
 
Join Date: Nov 2018
Posts: 18
Reputation: 0
Default Re: Need help with // command

Code:
if(strcmp(cmdtext, "//", true, 2) == 0 && PlayerDB[playerid][Loaded]) // If the player isn't an admin, the command is not available to them
    {
        if(PlayerDB[playerid][MutedPlayer] > 0)
    	{
        new string[144];
        SendClientMessage(playerid, RED, "! You can't use that command right now.);
        return 1;
    	}
        if(strlen(cmdtext) == 2) // The player typed '//' without any text!
        {
            SendClientMessage(playerid, WHITE,"* Use // [text]");

            return 0;
        }
        new string[152];
        format(string, sizeof(string), "[VIP CHAT] %s: %s", Nick(playerid), text[2]);

        foreach(new i : Player)
        {
            if(PlayerDB[i][LoggedIn] == 1 && PlayerDB[i][Loaded] == 1 && PlayerDB[i][VIP] > 0)
            {
                SendClientMessage(i, -1, string);
            }
        }
        return 0; // Return 0 here means that no other ZCMD command will be executed!
    }
Edvukas is offline   Reply With Quote
Old 26/05/2019, 12:48 PM   #4
OtimoJogo
Big Clucker
 
Join Date: Jul 2016
Posts: 160
Reputation: 2
Default Re: Need help with // command

pawn Code:
new cmd[128];
    new idx;
    new tmp[128];
    cmd = strtok(cmdtext, idx);

    if(strcmp(cmdtext, "/message", true) == 0 && PlayerDB[playerid][Loaded])
    {
        if(PlayerDB[playerid][MutedPlayer] > 0)
        {
          SendClientMessage(playerid, RED, "! You can't use that command right now.);
          return 1;
        }

        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, COLOR_RED, "
× Use: /message [message]");
        }

        new length = strlen(cmdtext);
        while ((idx < length) && (cmdtext[idx] <= ' '))
        {
            idx++;
        }
        new offset = idx;
        new result[64];
        while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
        {
            result[idx - offset] = cmdtext[idx];
            idx++;
        }
        result[idx - offset] = EOS;
        if(!strlen(result))
        {
            SendClientMessage(playerid, COLOR_RED, "
× enter a message.");
        }

        new string[152];
        format(string, sizeof(string), "
[VIP CHAT] %s: %s", Nick(playerid), result);

        foreach(new i : Player)
        {
            if(PlayerDB[i][LoggedIn] == 1 && PlayerDB[i][Loaded] == 1 && PlayerDB[i][VIP] > 0)
            {
                SendClientMessage(i, -1, string);
            }
        }
        return 0; // Return 0 here means that no other ZCMD command will be executed!
    }
   
   //puts this out of the callback OnPlayerCommandText()
  strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }
 
    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
   }

I made it here in the rush, see if it works out. Anything post the error here.
OtimoJogo is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with YCMD proces command and problem with "Server:Unknown command JoDe Scripting Help 1 20/04/2018 12:12 PM
[Plugin] mcmd Command Engine - Plugin based command processing Mellnik Plugin Development 108 08/05/2016 01:55 PM
i had this command in my gamemode, when i type this in game,it tells server unknow command? Chrisli520 Scripting Help 3 24/11/2013 10:02 AM
Executed ZCMD command returns SERVER: Unknown Command SexTourist Scripting Help 12 03/01/2012 03:38 PM
Slap command returns an Unknown Command when player is not connected HydraX Help Archive 16 01/08/2011 05:19 AM


All times are GMT. The time now is 03:50 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.