SA-MP Forums Archive
Small job with one checkpoint! - 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: Small job with one checkpoint! (/showthread.php?tid=84801)



Small job with one checkpoint! - Anarkien - 03.07.2009

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?


Re: Small job with one checkpoint! - refshal - 03.07.2009

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.


Re: Small job with one checkpoint! - Anarkien - 03.07.2009

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?


Re: Small job with one checkpoint! - Djiango - 03.07.2009

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;
}



Re: Small job with one checkpoint! - Anarkien - 03.07.2009

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.