First time scripting
#7

Quote:
Originally Posted by AndreT
Посмотреть сообщение
Welcome to SA-MP forums, YahyaBR.

It is good that you've done enough research on your own and actually have gotten somewhere. And your script is a lot like with what I started up with 6 years ago. The error line is indeed line 50 in your posted script.

The syntax of SendClientMessage is SendClientMessage(playerid, color, message[]). This means that the first 2 parameters are integers (playerid and color - the second parameter is often used with a HEX representation, though) and the 3rd parameter (message) is supposed to be an array.
A string message such as "Hey!" is actually an array and after you write a message, the [] characters are not required any more.

Please make sure you go through the useful documentation provided at the wiki. Start off with the basics.

// Edit: the problem in the second code is that you have 2 returns in the same code block. Returning means that the callback will stop processing the code. This is probably not what you want.
pawn Код:
if(!strcmp(cmdtext, "/command", true))
{
    // do something here...
}
return true;

// do something else here - but this code will generate a warning about unreachable code as you returned above! And this code won't be reached as the warning suggests.
return false;
Thank you very much for the explanation
but what should i do when im gonna add more command

EDIT:
this one answered my question
Quote:
Originally Posted by SilverKiller
Посмотреть сообщение
pawn Код:
RepairVehicle(GetPlayerVehicleID(playerid));
And for unreachable code, remove return 0 at test command, and then make the RepairVehicle fix command again.

Or just use my code:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/test", cmdtext, true, 10) == 0)
    {
        SendClientMessage(playerid, COLOR_BLACK, "[BR]Yahya__");
        SendClientMessage(playerid, COLOR_BLACK, "[BR]Yahya__");
        return 1;
    }
    if (strcmp("/fix", cmdtext, true, 10) == 0)
    {
        RepairVehicle(GetPlayerVehicleID(playerid));
        return 1;
    }
    return 0;
}
thanks for your guys helps
Reply


Messages In This Thread
First time scripting - by YahyaBR - 02.03.2013, 09:21
Re: First time scripting - by ikey07 - 02.03.2013, 09:29
Re: First time scripting - by SilverKiller - 02.03.2013, 09:33
Re: First time scripting - by YahyaBR - 02.03.2013, 09:44
Re: First time scripting - by AndreT - 02.03.2013, 09:48
Re: First time scripting - by SilverKiller - 02.03.2013, 09:49
Re: First time scripting - by YahyaBR - 02.03.2013, 11:42

Forum Jump:


Users browsing this thread: 1 Guest(s)