Simple commands
#1

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;
}
Reply
#2

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.
Reply
#3

THNX very mmuch
Reply
#4

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;
}
Reply
#5

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)