SA-MP Forums Archive
CarColour doesn't function good! - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: CarColour doesn't function good! (/showthread.php?tid=204483)



What's wrong with it ? - Yaszine - 29.12.2010

Hello everyone,

I have make a simple FS:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  return 1;
}
No errors but Ingame EX: /mycommand in FS works, the others in GM doesn't works!
Please


Re : CarColour doesn't function good! - Yaszine - 29.12.2010

Bump


Re: CarColour doesn't function good! - Mean - 29.12.2010

What the, and what should just a return 1; do ??
You should make a command...


Re : Re: CarColour doesn't function good! - Yaszine - 30.12.2010

Quote:
Originally Posted by Mean
Посмотреть сообщение
What the, and what should just a return 1; do ??
You should make a command...
I have a /carcolour under the OnPlayerCommandText just I make it hidden, I've just post the form of it here

When I'm ingame and type /carcolour & it's return 1; it function good but the other Cmds I have in the main GM not works
& When I set it to return 0; and in game tape /carcolour it works but it send also an UNKNOWN COMMAND under the USAGE: ........

Okay !


Re: CarColour doesn't function good! - MadeMan - 30.12.2010

Put return 0 at the end of the OnPlayerCommandText and return 1 at the end of the command.


Re : Re: CarColour doesn't function good! - Yaszine - 30.12.2010

Quote:
Originally Posted by MadeMan
Посмотреть сообщение
Put return 0 at the end of the OnPlayerCommandText and return 1 at the end of the command.
Still the same error !


Re: CarColour doesn't function good! - Macluawn - 30.12.2010

it actually doesn't matter what he returns at the end of it. show us the carcolour cmd, maybe a mistake is in that.


Re : CarColour doesn't function good! - Yaszine - 30.12.2010

This is my car colour command:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[128], idx;
    cmd = strtok(cmdtext, idx);
    if (strcmp("/carcolour", cmd, true) == 0)
    {
      new Colour1[128];
      new Colour2[128];
      new currentveh;
      Colour1 = strtok(cmdtext, idx);
      Colour2 = strrest(cmdtext, idx);
      currentveh = GetPlayerVehicleID(playerid);
      if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,RED,"You're not in a car.");
 if(IsPlayerInAnyVehicle(playerid))
    {
    if (!strval(Colour1) || strval(Colour1)> 255)
        {
        SendClientMessage(playerid, YELLOW, "Invalid colour1.");
        return 1;
        }
    else if (!strval(Colour2) || strval(Colour2) > 255)
        {
        SendClientMessage(playerid, YELLOW, "Invalid colour2.");
        return 1;
        }
 else {
    ChangeVehicleColor(currentveh, strval(Colour1), strval(Colour2));
    }
    }
    }
    return 0;
}
+ When I'm in a car and tape /carcolour and need to give for player USAGE: /carcolour id1 id2
because now, if I tape /carcolour it give me Invalid ID1 ?!
and when I write the full form Ex: /carcolour 3 6 it change my car's colour and give an Error msg: UNKNOWN COMMAND !

Please


Re: CarColour doesn't function good! - MadeMan - 30.12.2010

Quote:
Originally Posted by Macluawn
Посмотреть сообщение
it actually doesn't matter what he returns at the end of it.
It does matter.

https://sampwiki.blast.hk/wiki/Category:Scripting_Callbacks

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[128], idx;
    cmd = strtok(cmdtext, idx);
    if (strcmp("/carcolour", cmd, true) == 0)
    {
        new Colour1[128];
        new Colour2[128];
        new currentveh;
        Colour1 = strtok(cmdtext, idx);
        Colour2 = strrest(cmdtext, idx);
        currentveh = GetPlayerVehicleID(playerid);
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,RED,"You're not in a car.");
        if(IsPlayerInAnyVehicle(playerid))
        {
            if (!strval(Colour1) || strval(Colour1)> 255)
            {
                SendClientMessage(playerid, YELLOW, "Invalid colour1.");
                return 1;
            }
            else if (!strval(Colour2) || strval(Colour2) > 255)
            {
                SendClientMessage(playerid, YELLOW, "Invalid colour2.");
                return 1;
            }
            else
            {
                ChangeVehicleColor(currentveh, strval(Colour1), strval(Colour2));
            }
        }
        return 1;
    }
    return 0;
}



Re : CarColour doesn't function good! - Yaszine - 30.12.2010

Quote:
Originally Posted by Yaszine
Посмотреть сообщение
This is my car colour command:
+ When player in a car and tape /carcolour it well give to him USAGE: /carcolour id1 id2
because now, if I tape /carcolour it give me Invalid ID1 ?!
and /carcolour 158 it give me Invalid ID2?!
And what about that ?!