SA-MP Forums Archive
/convoy (playerid) - 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)
+--- Thread: /convoy (playerid) (/showthread.php?tid=504434)



/convoy (playerid) - DerickClark - 04.04.2014

User wont give same mission? random missions


pawn Код:
COMMAND:convoy(playerid, params[])
{
        new thing[128];
        SendMessageToAdmins(playerid, -1, "/convoy", params);
        if (strlen(thing) == 0)
        {
            SendClientMessage(playerid, WORK, "USAGE: /convoy [playerid]");
        }
        new rand;
        rand = random(sizeof(trucker));
        SetPVarInt(playerid, "PlayerMission", rand);
       
        if (GetPlayerTeam(playerid) == 1)
        {
            new m = GetVehicleModel(GetPlayerVehicleID(playerid));
            if(m == 514 || m == 515 || m == 403)
            {
                new t = GetVehicleModel(GetVehicleTrailer(GetPlayerVehicleID(playerid)));
                if (t == 435 || t == 450 || t == 584)
                {
                    if (GetPlayerVehicleSeat(playerid) == 0)
                    {

                        Trucker1(playerid);
                        SendClientMessage(playerid, WORK, "If you lose your trailer, you will need to re-attach it to deliver");
                    }
                    else
                    {
                        SendClientMessage(playerid, WORK, "You are not the driver of this vehicle");
                    }
                }
                else
                {
                    SendClientMessage(playerid, WORK, "You do not have the correct trailer, please go and attach one!");
                }
            }
            else
            {
                SendClientMessage(playerid, WORK, "You are not in a truck, please go and get one!");
            }
           
         }
         return 1;
}
pawn Код:
forward Trucker1(playerid);
public Trucker1(playerid)
{
    new rand = random(sizeof(trucker));
    PlayerInfo[playerid][StartingPoint] = rand;
    DisablePlayerCheckpoint(playerid);
    SetPlayerCheckpoint(playerid, trucker[rand][ux], trucker[rand][uy], trucker[rand][uz], 10);
}



Re: /convoy (playerid) - DerickClark - 04.04.2014

Anyone?


Re: /convoy (playerid) - Abagail - 04.04.2014

Maybe you could do:

foreach(Player, i) {
if(GetPVarInt(i, "PlayerMission" == random)
// Put code here //
}

That will check if any online player's currently have that mission.


Re: /convoy (playerid) - DerickClark - 04.04.2014

pawn Код:
foreach(Player, i) {
if(GetPVarInt(i, "PlayerMission" == random)
  new rand = random(sizeof(trucker));
}
like that?


What code should go there?


Re: /convoy (playerid) - Abagail - 04.04.2014

foreach(Player, i) {
if(GetPVarInt(i, "PlayerMission" == random)
return cmd_convoy(playerid, params[]);
}

You could re-call the command which will basically try this again, and if the random is the same or is being used it will keep looping the command until eventually it get's one not being used(hope-fully).


Re: /convoy (playerid) - DerickClark - 04.04.2014

I can do it like:
foreach(Player, i)
{
SetPVarInt(i, "PlayerMission", rand);
}



Still doing RandonMission.


Re: /convoy (playerid) - Abagail - 04.04.2014

That would give all the player's the same mission, I don't really get the point of that.


Re: /convoy (playerid) - DerickClark - 04.04.2014

Quote:
Originally Posted by Abagail
Посмотреть сообщение
That would give all the player's the same mission, I don't really get the point of that.
Still doing random missions. here is the command.


pawn Код:
COMMAND:convoy(playerid, params[])
{
        new thing[128];
        SendMessageToAdmins(playerid, -1, "/convoy", params);
        if (strlen(thing) == 0)
        {
            SendClientMessage(playerid, WORK, "USAGE: /convoy [playerid]");
        }
        new rand;
        rand = random(sizeof(trucker));
        //SetPVarInt(playerid, "PlayerMission", rand);
        foreach(Player, i)
        {
           SetPVarInt(i, "PlayerMission", rand);
        }

        if (GetPlayerTeam(playerid) == 1)
        {
            new m = GetVehicleModel(GetPlayerVehicleID(playerid));
            if(m == 514 || m == 515 || m == 403)
            {
                new t = GetVehicleModel(GetVehicleTrailer(GetPlayerVehicleID(playerid)));
                if (t == 435 || t == 450 || t == 584)
                {
                    if (GetPlayerVehicleSeat(playerid) == 0)
                    {

                        Trucker1(playerid);
                        SendClientMessage(playerid, WORK, "If you lose your trailer, you will need to re-attach it to deliver");
                    }
                    else
                    {
                        SendClientMessage(playerid, WORK, "You are not the driver of this vehicle");
                    }
                }
                else
                {
                    SendClientMessage(playerid, WORK, "You do not have the correct trailer, please go and attach one!");
                }
            }
            else
            {
                SendClientMessage(playerid, WORK, "You are not in a truck, please go and get one!");
            }
           
         }
         return 1;
}



Re: /convoy (playerid) - LocMax - 05.04.2014

If you don't want random missions then remove the
pawn Код:
new rand = random(..)
And assign the players who are included into the convoy to same mission.


Re: /convoy (playerid) - DerickClark - 05.04.2014

Quote:
Originally Posted by LocMax
Посмотреть сообщение
If you don't want random missions then remove the
pawn Код:
new rand = random(..)
And assign the players who are included into the convoy to same mission.
?!??