Small job with one checkpoint!
#1

So I've decided to move on and try to make something else than just boring DM scripts.
Now I'm going to make a job wich (at least for now) will include one checkpoint.

You have to be in a Sweeper vehicle (574) in order to start the one-checkpoint job.
pawn Код:
AddStaticVehicle(574,-80.5441,1129.1659,19.7422,207.9535,8,17); // Sweeper
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/start", cmdtext, true, 6) == 0)
    {
        if(IsPlayerInVehicle(playerid, 574))
        SetPlayerCheckpoint(playerid, -147.1910, 1146.1820, 19.5938, 3.0);
    }
    return 0;
}
pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
    GivePlayerMoney(playerid, 1000);
    DisablePlayerCheckpoint(playerid);
    return 1;
}
My problem is that whenever I try to type /start in-game, I get the message "Unknown Command" even though I've made it under OnPlayerCommandText.
What have I done wrong?
Reply
#2

I think that you have forgotten a return 1;

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/start", cmdtext, true, 6) == 0)
{
if(IsPlayerInVehicle(playerid, 574))
SetPlayerCheckpoint(playerid, -147.1910, 1146.1820, 19.5938, 3.0);
return 1;
}
return 0;
}
Try that.
Reply
#3

Thank you, now I don't get the Unknown Command anymore.
But now I have another question:
There's no checkpoint showing up when I do /start! The x,y,z are correct.
I'm also in the Street Sweeper. Isn't 574 the vehicle ID? Or is it the model ID?
Reply
#4

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp("/start", cmdtext, true, 6) == 0)
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            new vehid = GetPlayerVehicleID(playerid);
            if(GetVehicleModel(vehid) == 574)
            {
                SetPlayerCheckpoint(playerid, -147.1910, 1146.1820, 19.5938, 3.0);
            }
            else SendClientMessage(playerid, COLOR, "You need to be in a sweeper, to use this command!");
        }
        else SendClientMessage(playerid, COLOR, "You need to be in a vehicle, to use this command!");
        return 1;
    }
    return 0;
}
Reply
#5

Quote:
Originally Posted by |∞|-Рцппσĵσ-|∞|
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp("/start", cmdtext, true, 6) == 0)
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            new vehid = GetPlayerVehicleID(playerid);
            if(GetVehicleModel(vehid) == 574)
            {
                SetPlayerCheckpoint(playerid, -147.1910, 1146.1820, 19.5938, 3.0);
            }
            else SendClientMessage(playerid, COLOR, "You need to be in a sweeper, to use this command!");
        }
        else SendClientMessage(playerid, COLOR, "You need to be in a vehicle, to use this command!");
        return 1;
    }
    return 0;
}
Thank you!
A bit too advanced for me to figure at this stage of learning, but now I understand how to use SetPlayerCheckpoint, GetPlayerVehicleID and IsPlayerInAnyVehicle.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)