Please help
#1

Hello. So I am scripting the trucking server from scratch and I want to script the license for Truckers, so that they could choose the route by themselves, not like when the system automaticly chooses for them.


Here is some preview of the code:

PHP код:
enum MisLocationsCargoEnum
{
    
ID,
    
LoadName[128],
    
Float:LoadX,
    
Float:LoadY,
    
Float:LoadZ,
    
Float:UnloadX,
    
Float:UnloadY,
    
Float:UnloadZ,
    
Pay
}
new 
MisLocationsCargo[][MisLocationsCargoEnum] =
{
    {
0"Deliver Candy & Lollipops from Confectionery Factory to Doherty Warehouse"2661.2075, -1594.973413.0510, -2093.693894.952535.221414530},
    {
2"Deliver Caramels & Licorices from Confectionery Factory to Spiny Bed Warehouse"2661.2075, -1594.973413.05102401.33982751.349610.723214530}
}
stock T_Trucker(playerid)
{
    new 
vID GetPlayerVehicleID(playerid), string[2000];
    if(
GetVehicleModel(vID)== 515)
    {
        
printf("Debug line: 1st if statement passed");
        if(
IsTrailerAttachedToVehicle(vID))
        {
            
printf("Debug line: 2nd if statement passed");
            if(
GetVehicleModel(GetVehicleTrailer(vID)) == 435 || GetVehicleModel(GetVehicleTrailer(vID)) == 584)
            {
                if(
PlayerInfo[playerid][pConvoy] > 0)
                {
                    for(new 
0MAX_PLAYERSi++)
                    {
                        if(
PlayerInfo[i][pConvoy] == PlayerInfo[playerid][pConvoy])
                        {
                            
printf("Debug line: last if statement passed");
                            
MissionStatus[i] = 1;
                            new 
MisRand random(sizeof(MisLocationsCargo));
                            new 
LoadText[128], MissionText[128], Float:xFloat:yFloat:z;
                            
MisLocationsCargo[MisRand][LoadX];
                            
MisLocationsCargo[MisRand][LoadY];
                            
MisLocationsCargo[MisRand][LoadZ];
                            
unx[i] = MisLocationsCargo[MisRand][UnloadX];
                            
uny[i] = MisLocationsCargo[MisRand][UnloadY];
                            
unz[i] = MisLocationsCargo[MisRand][UnloadZ];
                            
iPay[i] = MisLocationsCargo[MisRand][Pay];
                            
SetPlayerCheckpoint(playeridxyz7);
                            
format(LoadText128"%s"MisLocationsCargo[MisRand][LoadName]);
                            
PlayerInfo[i][pWork] = 1;
                            
format(string2000"{259400}Mission: {FFFFFF}%s"LoadText);
                            
SendClientMessage(i0xFFFFFFFFstring);
                            
PlayerTextDrawSetString(iMission[playerid], MissionText);
                         }
                    }
                }
                else
                {
                    
printf("Debug line: last if statement passed");
                    
MissionStatus[playerid] = 1;
                    new 
MisRand random(sizeof(MisLocationsFluid));
                    new 
LoadText[128], MissionText[128], Float:xFloat:yFloat:z;
                    
MisLocationsFluid[MisRand][LoadX];
                    
MisLocationsFluid[MisRand][LoadY];
                    
MisLocationsFluid[MisRand][LoadZ];
                    
unx[playerid] = MisLocationsFluid[MisRand][UnloadX];
                    
uny[playerid] = MisLocationsFluid[MisRand][UnloadY];
                    
unz[playerid] = MisLocationsFluid[MisRand][UnloadZ];
                    
iPay[playerid] = MisLocationsFluid[MisRand][Pay];
                    
SetPlayerCheckpoint(playeridxyz7);
                    
format(LoadText128"%s"MisLocationsFluid[MisRand][LoadName]);
                    
format(MissionText128"~w~%s"MisLocationsFluid[MisRand][LoadName]);
                    
PlayerInfo[playerid][pWork] = 1;
                    
format(string2000"{259400}Mission: {FFFFFF}%s"LoadText);
                    
SendClientMessage(playerid0xFFFFFFFFstring);
                    
PlayerTextDrawSetString(playeridMission[playerid], MissionText);
                   }
                if(
GetVehicleModel(vID)== 450// Cargo Missions
                
{
                    
printf("Debug line: last if statement passed");
                    
MissionStatus[playerid] = 1;
                    new 
MisRand random(sizeof(MisLocationsOre));
                    new 
LoadText[128], MissionText[128], Float:xFloat:yFloat:z;
                    
MisLocationsOre[MisRand][LoadX];
                    
MisLocationsOre[MisRand][LoadY];
                    
MisLocationsOre[MisRand][LoadZ];
                    
unx[playerid] = MisLocationsOre[MisRand][UnloadX];
                    
uny[playerid] = MisLocationsOre[MisRand][UnloadY];
                    
unz[playerid] = MisLocationsOre[MisRand][UnloadZ];
                    
iPay[playerid] = MisLocationsOre[MisRand][Pay];
                    
SetPlayerCheckpoint(playeridxyz7);
                    
format(LoadText128"%s"MisLocationsOre[MisRand][LoadName]);
                    
format(MissionText128"~w~%s"MisLocationsOre[MisRand][LoadName]);
                    
PlayerInfo[playerid][pWork] = 1;
                    
format(string2000"{259400}Mission: {FFFFFF}%s"LoadText);
                    
SendClientMessage(playerid0xFFFFFFFFstring);
                    
PlayerTextDrawSetString(playeridMission[playerid], MissionText);
                }
             }
             else
             {
                
SendClientMessage(playerid, -1"You are not pulling a correct type of trailer");
             }
        }
        else
        {
     
SendClientMessage(playeridCOLOR_RED"Error: You must attach a trailer to your truck or the trailer attached is not used for job.");
        }
    }
    else
    {
        
SendClientMessage(playeridCOLOR_RED"Error: You must be in a truck to perform this!");
    }
    return 
1;
}
forward Loading(playerid);
public 
Loading(playerid)
{
    
DisablePlayerCheckpoint(playerid);
    
ClearActorAnimations(InjuredBarber);
    
DestroyActor(InjuredBarber);
    
SetPlayerCheckpoint(playeridunx[playerid], uny[playerid], unz[playerid], 7);
    
SendClientMessage(playeridCOLOR_ORANGE"You're trailer is now loaded. Be sure to don't loose it.");
    
TogglePlayerControllable(playerid,1);
    
MissionStatus[playerid] = 2;
}
forward UnLoading(playerid);
public 
UnLoading(playerid)
{
    new 
vehicleid GetPlayerVehicleID(playerid), string[256];
    
PlayerTextDrawSetString(playeridMission[playerid], NonWorkMessage);
    
DisablePlayerCheckpoint(playerid);
    
GivePlayerMoney(playeridiPay[playerid]);
    
format(string256"Well done! You got 2 points and %d$ as reward."iPay[playerid]);
    
SendClientMessage(playeridCOLOR_GREENstring);
    
DetachTrailerFromVehicle(vehicleid);
    
TogglePlayerControllable(playerid,1);
    
PlayAudioStreamForPlayer(playerid"http://k002.kiwi6.com/hotlink/idmb12174a/taskfinishet.mp3");
    
SetPlayerScore(playeridGetPlayerScore(playerid)+2);
    
PlayerInfo[playerid][pScore] +=2;
    
MissionStatus[playerid] = 0;

Reply
#2

"new MisRand = random(sizeof(MisLocationsCargo)); "
That would be that line.
Reply
#3

I don't get you, but I want to make like this:

PHP код:
if (dialogid == DIALOG_TRUCKER_TASKBOOK)
    {
         new 
MisRand random(sizeof(MisLocationsCargo));
         if(
response)
         {
            if(
PlayerInfo[playerid][pClass] == 1)
            {
            switch(
listitem)
            {
                 case 
0:
                 {
                    {
4"Deliver Clothes from Fabrics Factory to SF SubUrbs."2262.7153, -1937.397013.5766, -2496.2271, -29.086125.523111000}                
                 }
                 case 
1:
                 {
                    
SetPlayerCheckpoint(playerid1982.6150, -220.6680, -0.24323.0);
                                }
                 case 
2:
                 {
                    
SetPlayerCheckpoint(playerid1982.6150, -220.6680, -0.24323.0);
                                }
                 }
            }
        }
    } 
I want the stock T_Trucker to be somehow connected to Dialog
Reply
#4

If you want to add stock with the dialog use T_Trucker(playerid); in the dialog it will automatically add it.
Reply
#5

Quote:
Originally Posted by fuckingcruse
Посмотреть сообщение
If you want to add stock with the dialog use T_Trucker(playerid); in the dialog it will automatically add it.
Where exactly I must add it?
Reply
#6

When person enters the truck.

Код:
    new str[512];
    for(new i=0; i<MAX_ROUTES_YOU_DEFINED; i++)
    {
        if(strlen(MisLocationsCargo[i][LoadName])) format(str, 512, "%s%s\n", str, MisLocationsCargo[i][LoadName]);
    }
    ShowPlayerDialog(playerid, DIALOG_TRUCKER_TASKBOOK, DIALOG_STYLE_LIST, str, "Choose", "Done");
OnDialogResponse

Код:
if (dialogid == DIALOG_TRUCKER_TASKBOOK) 
    { 
          if(response) 
          { 
            if(PlayerInfo[playerid][pClass] == 1) 
            { 
                SetPlayerCheckpoint(playerid, MisLocationsCargo[listitem][LoadX], MisLocationsCargo[listitem][LoadY], MisLocationsCargo[listitem][LoadZ]);
            }
          }
    }
Reply
#7

Should it be like this?

PHP код:
CMD:taskbook(playeridparams[])
{
    new 
str[512];
    for(new 
i=0i<MAX_ROUTES_YOU_DEFINEDi++)
    {
        if(
strlen(MisLocationsCargo[i][LoadName])) format(str512"%s%s\n"strMisLocationsCargo[i][LoadName]);
    }
    
ShowPlayerDialog(playeridDIALOG_TRUCKER_TASKBOOKDIALOG_STYLE_LISTstr"Choose""Done");
    }
    return 
1;

Or I had to add that OnPlayerStateChange or OnPlayerEnterVehicle and then IsPlayerInVehicle..?
Reply
#8

Can anyone help me to solve this please?
Reply
#9

Well thank you for calling my script yours and made from scratch, seeing that you couldn't even spend 5 seconds to remove the debugging lines added by me.

You must make a dialog with the available locations and set the checkpoint for the position he will chose. Each listitem corresponds to an location that the player will select from the dialog.

About that tasklist command, I suggest you adding a check if a player is in a truck so they can execute the command. At any case, I haven't checked the code of that dialog and I wont. I suggest you to learn coding before trying to do things on your own.
Reply
#10

Quote:
Originally Posted by D1am0nd
Посмотреть сообщение
Can anyone help me to solve this please?
This is why you ignore those who simply post up single line fixes, because they usually don't even have a clue and are simply guessing.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)