Checkpoints for /guide.
#1

Hello, i havent tested this script, but this is what i have so far.
pawn Код:
if (strcmp("/guide", cmdtext, true, 10) == 0)
    {
        SendClientMessage(playerid, COLOR_RED, "You have opened your guide booklet.");
        SendClientMessage(playerid, COLOR_RED, "First, we start off showing you where the bank is");
        SendClientMessage(playerid, COLOR_RED, "You can Deposit and Withdraw money in here.");
        SetPlayerCheckpoint(playerid, 1462.6707, -1022.0826, 23.8281, 3.0);
        SendClientMessage(playerid, COLOR_RED, "A marker has been set at the bank.");
        return 1;
    }
   
    return 0;
}
And i have this in public OnPlayerEnterCheckpoint(playerid)
pawn Код:
DisablePlayerCheckpoint(playerid);
    return 1;
}
I need help figuring out when you do /guide, and you goto the marker where the bank is, it will reset and say something like "Good, you found a bank, now to the LSPD" or something and it will set one next to the LSPD.

Dont be a troller/hater, i am a new scripter.
Thanks
Da(fuckin)Realz.
Reply
#2

Anyone know how to do this?
Reply
#3

pawn Код:
if (strcmp("/guide", cmdtext, true) == 0)
    {
        SendClientMessage(playerid, COLOR_RED, "You have opened your guide booklet.");
        SendClientMessage(playerid, COLOR_RED, "First, we start off showing you where the bank is");
        SendClientMessage(playerid, COLOR_RED, "You can Deposit and Withdraw money in here.");
        SetPlayerCheckpoint(playerid, 1462.6707, -1022.0826, 23.8281, 3.0);
        SetPVarInt(playerid, "Guide", 1);
        SendClientMessage(playerid, COLOR_RED, "A marker has been set at the bank.");
        return 1;
    }
pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
    switch(GetPVarInt(playerid, "Guide"))
    {
        case 1:
        {
            SendClientMessage(playerid, COLOR_RED, "Good, you found a bank, now to the LSPD");
            SetPlayerCheckpoint(playerid, ...);
            SetPVarInt(playerid, "Guide", 2);
        }
        case 2:
        {
            SendClientMessage(playerid, COLOR_RED, "Good, you found the LSPD, now to ...");
            SetPlayerCheckpoint(playerid, ...);
            SetPVarInt(playerid, "Guide", 3);
        }
        ...
    }
    return 1;
}
Reply
#4

Thanks man this helps me too!
Reply
#5

assign each checkpoint a id too you will be able to use them better
at the top...
pawn Код:
#define COLOR_RED               0xAA3333FF
#define MAX_CHECKPOINTS 2//total checkpoints

#define CPBANK          0//cpid for bank
#define NOWHERE 1 //define a name for each cp id here

enum checkpointinfo {
    CPID,
    Float:X,
    Float:Y,
    Float:Z,
    Float:Size
};
new Checkpoints[MAX_CHECKPOINTS][checkpointinfo]={
//  X            Y          Z    Size
{CPBANK,1462.6707, -1022.0826, 23.8281, 3.0},
//add more cps here
{NOWHERE,0.0,0.0,0.0,3.0)
};

new PlayersCheckpoint[MAX_PLAYERS];//tracks the player current checkpoint
then make something like...
pawn Код:
stock SetGameCheckpoint(playerid,cpid){
    DisablePlayerCheckpoint(playerid);
    PlayersCheckpoint[playerid] = cpid;//save players new checkpoint id
    SetPlayerCheckpoint(playerid,Checkpoints[cpid][X],Checkpoints[cpid][Y],Checkpoints[cpid][Z],Checkpoints[cpid][Size]);//load the cp
}
then your command
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/guide", cmdtext, true, 10) == 0)
    {
        SendClientMessage(playerid, COLOR_RED, "You have opened your guide booklet.");
        SendClientMessage(playerid, COLOR_RED, "First, we start off showing you where the bank is");
        SendClientMessage(playerid, COLOR_RED, "You can Deposit and Withdraw money in here.");
        SendClientMessage(playerid, COLOR_RED, "A marker has been set at the bank.");
        SetGameCheckpoint(playerid,CPBANK);//use our little command to load the cp
        SetPVarInt(playerid, "Guide", 1);
        return 1;
    }
    return 0;
}
and now onplayercheckpoint we know what cp the player is at
pawn Код:
public OnPlayerEnterCheckpoint(playerid){
    new cpid = PlayersCheckpoint[playerid]; //lookup current cp
    if(GetPVarInt(playerid, "Guide") > 0){//is player doing the guide?
        switch(GetPVarInt(playerid, "Guide"))  {
            case 1: {
                SendClientMessage(playerid, COLOR_RED, "Good, you found a bank, now to the LSPD");
                SetGameCheckpoint(playerid,NOWHERE);
                SetPVarInt(playerid, "Guide", 2);
            }
            case 2:{
                SendClientMessage(playerid, COLOR_RED, "Good, you found the LSPD, now to ...");
                SetGameCheckpoint(playerid,CPBANK);
                SetPVarInt(playerid, "Guide", 3);
            }
        }
        switch(cpid){
            case CPBANK:{
                SendClientMessage(playerid, COLOR_RED, "Welcome to the bank you balance is $32809138932");
            }
            case NOWHERE:{
                SendClientMessage(playerid, COLOR_RED, "Where the hell am i...");
            }

        }
    }
    return 1;
}
then with the help of something like... to return the distance between the player and the cp
pawn Код:
stock GetPlayerDistanceToPoint(playerid,Float:x,Float:y){ //By Sacky (Edited by Smugller)
    new Float:x1,Float:y1,Float:z1;
    new Float:dis;
    GetPlayerPos(playerid,x1,y1,z1);
    dis = floatsqroot((x-x1)*(x-x1)+(y-y1)*(y-y1));
    return floatround(dis);
}
you can make functin to set the players cloest cp...
pawn Код:
stock CheckpointUpdatd(playerid){
    new cprange = 10000,cpid;
    new(new i=0;i<MAX_CHECKPOINTS;i++){
        new tmp;
        tmp = GetPlayerDistanceToPoint(playerid,Checkpoints[cpid][X],Checkpoints[cpid][Y]);
        if(tmp < cprange){
            cprange = tmp
            cpid = i;
        }
    }
    SetGameCheckpoint(playerid,cpid);
}
Reply
#6

Quote:
Originally Posted by MadeMan
Посмотреть сообщение
pawn Код:
if (strcmp("/guide", cmdtext, true) == 0)
    {
        SendClientMessage(playerid, COLOR_RED, "You have opened your guide booklet.");
        SendClientMessage(playerid, COLOR_RED, "First, we start off showing you where the bank is");
        SendClientMessage(playerid, COLOR_RED, "You can Deposit and Withdraw money in here.");
        SetPlayerCheckpoint(playerid, 1462.6707, -1022.0826, 23.8281, 3.0);
        SetPVarInt(playerid, "Guide", 1);
        SendClientMessage(playerid, COLOR_RED, "A marker has been set at the bank.");
        return 1;
    }
pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
    switch(GetPVarInt(playerid, "Guide"))
    {
        case 1:
        {
            SendClientMessage(playerid, COLOR_RED, "Good, you found a bank, now to the LSPD");
            SetPlayerCheckpoint(playerid, ...);
            SetPVarInt(playerid, "Guide", 2);
        }
        case 2:
        {
            SendClientMessage(playerid, COLOR_RED, "Good, you found the LSPD, now to ...");
            SetPlayerCheckpoint(playerid, ...);
            SetPVarInt(playerid, "Guide", 3);
        }
        ...
    }
    return 1;
}

Thanks this helped me, but do u (or anyone reading this) know how to make it so that name will not be able to use the /guide again, because i dont want them spamming it due to me putting it so that they get 1k at the end of it.
Reply
#7

like this
pawn Код:
if (strcmp("/guide", cmdtext, true) == 0){
        if(GetPVarInt(playerid, "Guide") > 0){
            SendClientMessage(playerid, COLOR_RED, "You can only use the 'guide' command once per visit.");
return 1;
        }
        SendClientMessage(playerid, COLOR_RED, "You have opened your guide booklet.");
        SendClientMessage(playerid, COLOR_RED, "First, we start off showing you where the bank is");
        SendClientMessage(playerid, COLOR_RED, "You can Deposit and Withdraw money in here.");
        SetPlayerCheckpoint(playerid, 1462.6707, -1022.0826, 23.8281, 3.0);
        SetPVarInt(playerid, "Guide", 1);
        SendClientMessage(playerid, COLOR_RED, "A marker has been set at the bank.");
        return 1;
    }
Reply
#8

Do you have a login/register system? If you do, simply add a "Guide" and once it is done you can set it as one. Then (for mysql) Have a check, and then if there is no 1 beside Guide, it will show it, else it will say "Sorry you have already done the guide".

Sorry if that didn't make any sense, I just woke up :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)