SA-MP Forums Archive
Convoy Random Missions. - 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 Random Missions. (/showthread.php?tid=583244)



Convoy Random Missions. - DerickClark - 27.07.2015

When a id 0 type /work, and id 1 types /convoy 0 to work with him. But it do random mission to id 1. here my commands and stock.



pawn Код:
CMD:work(playerid, params[])
{
    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);
                    new string[244];
                    truck_PlayerJob[playerid] = 1;
                    Convoy++;
                    PlayerInfo[playerid][pConvoy] = Convoy;
                    format(string, 128, "%s has created a convoy. Join him by double-clicking his name on the ''Tab'' list.");
                    SendClientMessageToAll(-1, string);
                    //truckchecktime = SetTimerEx("TruckCheck", 1000, true, "i", giveplayerid);
                }
                else
                {
                    SendClientMessage(playerid, -1, "You are not the driver of this vehicle");
                }
            }
            else
            {
                SendClientMessage(playerid, -1, "You do not have a trailer, please go and ATTACH one!");
            }
        }
        else
        {
            SendClientMessage(playerid, -1, "You are not in a TRUCK, please go and get one!");
        }
    }
    return 1;
}

forward Trucker1(playerid);
public Trucker1(playerid)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PlayerInfo[i][pConvoy] == PlayerInfo[playerid][pConvoy])
        {
            if(IsPlayerConnected(i)) //foreach is the better option
            {
                new rand = random(sizeof(trucker));
                new Text:Work[MAX_PLAYERS];
                new newtext2[MAX_PLAYERS];
                PlayerInfo[playerid][StartingPoint] = rand;
                DisablePlayerCheckpoint(i);
                SetPlayerCheckpoint(i, trucker[rand][lx], trucker[rand][ly], trucker[rand][lz], 10);
                format(newtext2,sizeof(newtext2), "~w~Go to~r~%s ~w~to load your trailer with ~y~%s", trucker[rand][lpname], trucker[rand][loadname]);
                TextDrawSetString(Work[i],newtext2);
                SetPVarInt(playerid, "PlayerMission", 1); // Set the Player mission.
            }
        }
    }
}







pawn Код:
CMD:convoy(playerid, params[])
{
    new thing[128];
    new giveplayerid = ReturnUser(thing);
    if(sscanf(params, "u",thing)) return SendClientMessage(playerid, -1, "USAGE: /convoy [playerid]");
    new rand = random(sizeof(trucker));
    rand = GetPVarInt(giveplayerid, "PlayerMission");
    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)
                {
                    PlayerInfo[playerid][pConvoy] = PlayerInfo[playerid][pConvoy];
                    new newtext2[MAX_PLAYERS];
                    new Text:Work[MAX_PLAYERS];
                    PlayerInfo[playerid][StartingPoint] = rand;
                    DisablePlayerCheckpoint(playerid);
                    SetPlayerCheckpoint(playerid, trucker[rand][lx], trucker[rand][ly], trucker[rand][lz], 10);
                    format(newtext2,sizeof(newtext2), "~w~Head to ~r~%s ~w~to load your trailer with ~y~%s", trucker[rand][lpname], trucker[rand][loadname]);
                    TextDrawSetString(Work[playerid],newtext2);
                    truck_PlayerJob[playerid] = 1;
                }
                else
                {
                    new string[240];
                    format(string, 128, "That player isn't at the driver seat of the vehicle.");
                    SendClientMessage(playerid, 0xFFFFFFFF, string);
                }
            }
            else
            {
                new string[240];
                format(string, 128, "That player doesn't have the correct trailer, tell him to attach one!");
                SendClientMessage(playerid, 0xFFFFFFFF, string);
            }
        }
        else
        {
            new string[240];
            format(string, 128, "That player isn't on a truck, tell him to get one!");
            SendClientMessage(playerid, 0xFFFFFFFF, string);
        }
    }
    return 1;
}



Re: Convoy Random Missions. - DarkLored - 27.07.2015

pawn Код:
CMD:convoy(playerid, params[])
{
    new thing[128];
    new giveplayerid = ReturnUser(thing);
    if(sscanf(params, "u",thing)) return SendClientMessage(playerid, -1, "USAGE: /convoy [playerid]");
    new rand = random(sizeof(trucker));
    rand = GetPVarInt(giveplayerid, "PlayerMission");
    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)
                {
                    PlayerInfo[thing][pConvoy] = PlayerInfo[playerid][pConvoy];
                    new newtext2[MAX_PLAYERS];
                    new Text:Work[MAX_PLAYERS];
                    PlayerInfo[playerid][StartingPoint] = rand;
                    DisablePlayerCheckpoint(playerid);
                    SetPlayerCheckpoint(playerid, trucker[rand][lx], trucker[rand][ly], trucker[rand][lz], 10);
                    format(newtext2,sizeof(newtext2), "~w~Head to ~r~%s ~w~to load your trailer with ~y~%s", trucker[rand][lpname], trucker[rand][loadname]);
                    TextDrawSetString(Work[playerid],newtext2);
                    truck_PlayerJob[playerid] = 1;
                }
                else
                {
                    new string[240];
                    format(string, 128, "That player isn't at the driver seat of the vehicle.");
                    SendClientMessage(playerid, 0xFFFFFFFF, string);
                }
            }
            else
            {
                new string[240];
                format(string, 128, "That player doesn't have the correct trailer, tell him to attach one!");
                SendClientMessage(playerid, 0xFFFFFFFF, string);
            }
        }
        else
        {
            new string[240];
            format(string, 128, "That player isn't on a truck, tell him to get one!");
            SendClientMessage(playerid, 0xFFFFFFFF, string);
        }
    }
    return 1;
}
the only logical explanation to your problem is the PlayerInfo[playerid][pConvoy] = PlayerInfo[playerid][pConvoy] it sets what's already been set for the same user. try the code I gave you.


Re: Convoy Random Missions. - DerickClark - 27.07.2015

Another problem is

pawn Код:
(1471) : error 033: array must be indexed (variable "thing")
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
pawn Код:
Error Line: PlayerInfo[thing][pConvoy] = PlayerInfo[playerid][pConvoy];



Re: Convoy Random Missions. - DarkLored - 27.07.2015

replace thing with giveplayerid, can you explain why you created 'thing' and why not just use a targeted ID it would be more simple if you'd use
pawn Код:
new ID;



Re: Convoy Random Missions. - DerickClark - 27.07.2015

Idk, i use thing for id.
when i typed /work then /convoy 0 it skipped the mission and i kept doing it. still on the same mission type
it set to Kac to (LV) Books store not the player mission it not set to id 0 mission.
pawn Код:
CMD:convoy(playerid, params[])
{
    //new ID = ReturnUser(ID);
    new ID;
    if(sscanf(params, "u",ID)) return SendClientMessage(playerid, -1, "USAGE: /convoy [playerid]");
    new rand = random(sizeof(trucker));
    rand = GetPVarInt(ID, "PlayerMission");
    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)
                {
                    PlayerInfo[ID][pConvoy] = PlayerInfo[playerid][pConvoy];
                    new newtext2[MAX_PLAYERS];
                    new Text:Work[MAX_PLAYERS];
                    PlayerInfo[playerid][StartingPoint] = rand;
                    DisablePlayerCheckpoint(playerid);
                    SetPlayerCheckpoint(playerid, trucker[rand][lx], trucker[rand][ly], trucker[rand][lz], 10);
                    format(newtext2,sizeof(newtext2), "~w~Head to ~r~%s ~w~to load your trailer with ~y~%s", trucker[rand][lpname], trucker[rand][loadname]);
                    TextDrawSetString(Work[playerid],newtext2);
                    truck_PlayerJob[playerid] = 1;
                }
                else
                {
                    new string[240];
                    format(string, 128, "That player isn't at the driver seat of the vehicle.");
                    SendClientMessage(playerid, 0xFFFFFFFF, string);
                }
            }
            else
            {
                new string[240];
                format(string, 128, "That player doesn't have the correct trailer, tell him to attach one!");
                SendClientMessage(playerid, 0xFFFFFFFF, string);
            }
        }
        else
        {
            new string[240];
            format(string, 128, "That player isn't on a truck, tell him to get one!");
            SendClientMessage(playerid, 0xFFFFFFFF, string);
        }
    }
    return 1;
}
pawn Код:
new trucker[2][MissionData] =
{
    {2054.6843,1928.2374,12.1540, "(LV) books store", "Books", 2492.5366,2773.2190,10.80422, "KAC", 2500},
    {2492.5366,2773.2190,10.80422, "KAC", "Books", 2054.6843,1928.2374,12.1540, "(LV) books store", 2500}
};



Re: Convoy Random Missions. - DarkLored - 27.07.2015

The problem is that you are randomizing the coords for both of them instead of doing it for one of them and then setting the same coords to the other for example randomize one players coords and then use PlayerInfo[targetid][StartingPoint] = PlayerInfo[playerid][StartingPoint];

and simply set a checkpoint for both.


Re: Convoy Random Missions. - DerickClark - 27.07.2015

Still doing it but idk if im doing it right.

pawn Код:
CMD:convoy(playerid, params[])
{
    //new ID = ReturnUser(ID);
    new targetid;
    if(sscanf(params, "u",targetid)) return SendClientMessage(playerid, -1, "USAGE: /convoy [playerid]");

    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)
                {
                    PlayerInfo[targetid][pConvoy] = PlayerInfo[playerid][pConvoy];
                    new newtext2[MAX_PLAYERS];
                    new Text:Work[MAX_PLAYERS];
                    //PlayerInfo[playerid][StartingPoint] = rand;
                    PlayerInfo[targetid][StartingPoint] = PlayerInfo[playerid][StartingPoint];
                    DisablePlayerCheckpoint(playerid);
                    SetPlayerCheckpoint(playerid, trucker[targetid][lx], trucker[targetid][ly], trucker[targetid][lz], 10);
                    format(newtext2,sizeof(newtext2), "~w~Head to ~r~%s ~w~to load your trailer with ~y~%s", trucker[targetid][lpname], trucker[targetid][loadname]);
                    TextDrawSetString(Work[playerid],newtext2);
                    truck_PlayerJob[playerid] = 1;
                }
                else
                {
                    new string[240];
                    format(string, 128, "That player isn't at the driver seat of the vehicle.");
                    SendClientMessage(playerid, 0xFFFFFFFF, string);
                }
            }
            else
            {
                new string[240];
                format(string, 128, "That player doesn't have the correct trailer, tell him to attach one!");
                SendClientMessage(playerid, 0xFFFFFFFF, string);
            }
        }
        else
        {
            new string[240];
            format(string, 128, "That player isn't on a truck, tell him to get one!");
            SendClientMessage(playerid, 0xFFFFFFFF, string);
        }
    }
    return 1;
}



Re: Convoy Random Missions. - DerickClark - 27.07.2015

it's not set to the right player mission.


AW: Convoy Random Missions. - Macronix - 27.07.2015

Try this:

Код:
CMD:convoy(playerid, params[])
{
    //new ID = ReturnUser(ID);
    new targetid;
    if(sscanf(params, "u",targetid)) return SendClientMessage(playerid, -1, "USAGE: /convoy [playerid]");

    if(GetPlayerTeam(targetid) == 1)
    {
        new m = GetVehicleModel(GetPlayerVehicleID(targetid));
        if(m == 514 || m == 515 || m == 403)
        {
            new t = GetVehicleModel(GetVehicleTrailer(GetPlayerVehicleID(targetid)));
            if (t == 435 || t == 450 || t == 584)
            {
                if (GetPlayerVehicleSeat(targetid) == 0)
                {
                    PlayerInfo[playerid][pConvoy] = PlayerInfo[targetid][pConvoy];
                    new newtext2[MAX_PLAYERS];
                    new Text:Work[MAX_PLAYERS];
                    //PlayerInfo[playerid][StartingPoint] = rand;
                    PlayerInfo[playerid][StartingPoint] = PlayerInfo[targetid][StartingPoint];
	                DisablePlayerCheckpoint(playerid);
            	    SetPlayerCheckpoint(playerid, trucker[targetid][lx], trucker[targetid][ly], trucker[targetid][lz], 10);
                    format(newtext2,sizeof(newtext2), "~w~Head to ~r~%s ~w~to load your trailer with ~y~%s", trucker[targetid][lpname], trucker[targetid][loadname]);
                    TextDrawSetString(Work[playerid],newtext2);
                    truck_PlayerJob[playerid] = 1;
                }
                else
                {
                   	new string[240];
                    format(string, 128, "That player isn't at the driver seat of the vehicle.");
                    SendClientMessage(playerid, 0xFFFFFFFF, string);
                }
            }
            else
            {
               	new string[240];
                format(string, 128, "That player doesn't have the correct trailer, tell him to attach one!");
                SendClientMessage(playerid, 0xFFFFFFFF, string);
            }
        }
        else
        {
 			new string[240];
            format(string, 128, "That player isn't on a truck, tell him to get one!");
            SendClientMessage(playerid, 0xFFFFFFFF, string);
        }
    }
    return 1;
}



Re: AW: Convoy Random Missions. - DerickClark - 27.07.2015

Quote:
Originally Posted by Macronix
Посмотреть сообщение
Try this:

Код:
CMD:convoy(playerid, params[])
{
    //new ID = ReturnUser(ID);
    new targetid;
    if(sscanf(params, "u",targetid)) return SendClientMessage(playerid, -1, "USAGE: /convoy [playerid]");

    if(GetPlayerTeam(targetid) == 1)
    {
        new m = GetVehicleModel(GetPlayerVehicleID(targetid));
        if(m == 514 || m == 515 || m == 403)
        {
            new t = GetVehicleModel(GetVehicleTrailer(GetPlayerVehicleID(targetid)));
            if (t == 435 || t == 450 || t == 584)
            {
                if (GetPlayerVehicleSeat(targetid) == 0)
                {
                    PlayerInfo[playerid][pConvoy] = PlayerInfo[targetid][pConvoy];
                    new newtext2[MAX_PLAYERS];
                    new Text:Work[MAX_PLAYERS];
                    //PlayerInfo[playerid][StartingPoint] = rand;
                    PlayerInfo[playerid][StartingPoint] = PlayerInfo[targetid][StartingPoint];
	                DisablePlayerCheckpoint(playerid);
            	    SetPlayerCheckpoint(playerid, trucker[targetid][lx], trucker[targetid][ly], trucker[targetid][lz], 10);
                    format(newtext2,sizeof(newtext2), "~w~Head to ~r~%s ~w~to load your trailer with ~y~%s", trucker[targetid][lpname], trucker[targetid][loadname]);
                    TextDrawSetString(Work[playerid],newtext2);
                    truck_PlayerJob[playerid] = 1;
                }
                else
                {
                   	new string[240];
                    format(string, 128, "That player isn't at the driver seat of the vehicle.");
                    SendClientMessage(playerid, 0xFFFFFFFF, string);
                }
            }
            else
            {
               	new string[240];
                format(string, 128, "That player doesn't have the correct trailer, tell him to attach one!");
                SendClientMessage(playerid, 0xFFFFFFFF, string);
            }
        }
        else
        {
 			new string[240];
            format(string, 128, "That player isn't on a truck, tell him to get one!");
            SendClientMessage(playerid, 0xFFFFFFFF, string);
        }
    }
    return 1;
}
still ain't working, its skip mission, didnt even get the id 0 mission.