SA-MP Forums Archive
Simple commands - 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: Simple commands (/showthread.php?tid=409475)



Simple commands - SonOussi - 21.01.2013

Hey evrybody ,
I have a problem with scripting .
I want to create simple commands like /kill and /help but i get this error 035: argument type mismatch (argument 2)
this is my code
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/kill", cmdtext, true, 10) == 0)
    {
	SetPlayerHealth(playerid, 0) ;
	return 1;
}
    if (strcmp("/help", cmdtext, true, 10) == 0)
    {
    SendClientMessage(playerid, "Welcome To Draguto Server ") ;
    return 1;
}
	return 0;
}



Re: Simple commands - Jeffry - 21.01.2013

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    //I removed the ',10' in the end, because it means it will check the first 10 letters only.
    if(strcmp("/kill", cmdtext, true) == 0)
    {
        SetPlayerHealth(playerid, 0.0) ;
        return 1;
    }
    if(strcmp("/help", cmdtext, true) == 0)
    {
        SendClientMessage(playerid, 0x00FF00, "Welcome To Draguto Server ");
        //playerid = the player     0x00FF00 = color    "..." = text message.
        return 1;
    }
    return 0;
}
Fixed your Indentation as well.


Re: Simple commands - SonOussi - 21.01.2013

THNX very mmuch


Re: Simple commands - azzerking - 21.01.2013

Hey, you missed the COLOR off the SendClientMessage(playerid, COLOR, "LOL");

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/kill", cmdtext, true, 10) == 0)
    {
        SetPlayerHealth(playerid, 0);
        return 1;
    }
    if (strcmp("/help", cmdtext, true, 10) == 0)
    {
        SendClientMessage(playerid, RED, "Welcome To Draguto Server ") ;
        return 1;
    }
    return 0;
}



Re: Simple commands - Private200 - 21.01.2013

Same error as me when i started scripting , i was same like you , but no worries , you'll learn

pawn Код:
//At top of the script :

#define COLOR_RED 0xAA3333AA

// Somewhere at your script :

public OnPlayerCommandText(playerid, cmdtext[])
{
     if (strcmp("/kill", cmdtext, true, 10) == 0)
    {
    SetPlayerHealth(playerid, 0) ;
    return 1;
}
    if (strcmp("/help", cmdtext, true, 10) == 0)
    {
    SendClientMessage(playerid, COLOR_RED,"Welcome To Draguto Server ") ;
    //The "SendClientMessage" is like : SendClientMessage(playerid, color, "message here");
    return 1;
    }
    return 0;
}
For other colors go on this : https://sampforum.blast.hk/showthread.php?tid=157789 .

Add all those colors in top of your script and then just use the message in the ( COLOR_RED or COLOR_BLUE etc )

Good luck