:work with switch
#1

i tried to use switch here but it doesnt work at all.

PHP код:
YCMD:work(playeridparams[], help)
{
    if(
IsWorking[playerid] == 1) return SendClientMessage(playeridCOLOR_WHITE"Already working.");
    for(new 
1MAX_JOBSj++) 
    {
        if(
PlayerToPoint(3.0playeridJobInfo[j][jPosX], JobInfo[j][jPosY], JobInfo[j][jPosZ]) && != 7
        {
            switch(
j)
            {
                case 
1:
                {
                }
                case 
2:
                {
                    
PWarehouseCP[playerid] = 2;
                    
PWarehouseCurrent[playerid] = 0;
                    
IsWorking[playerid] = 1;
                    new 
randn random(sizeof(WarehouseExteriorCP));
                    
SetPlayerCheckpoint(playeridWarehouseExteriorCP[randn][0], WarehouseExteriorCP[randn][1], WarehouseExteriorCP[randn][2], 1.0);
                    
SetDestination(playeridWarehouseExteriorCP[randn][0], WarehouseExteriorCP[randn][1], WarehouseExteriorCP[randn][2]);
                }
                case 
3:
                {
                }
                case 
4:
                {
                }
                case 
5:
                {
                
                    
ShowPlayerDialog(playeridDIALOG_TRUCKERDIALOG_STYLE_TABLIST_HEADERS"Choose the transport type""Type\tLegal/Illegal\tAvailable routes\tReward\nFood\tLegal\t25\t{4AE87D}${FFFFFF}\nElectronics\tLegal\t25\t{4AE87D}${FFFFFF}\nGas/Petrol\tLegal\t15\t{4AE87D}${FFFFFF}\nCar Theft\tIllegal\t2\t{4AE87D}${FFFFFF} + {F37138}special rewards{FFFFFF}""Choose""Cancel");
                    new 
randn random(sizeof(TruckStart));
                    
VJob[playerid] = CreateVehicle(515TruckStart[randn][0], TruckStart[randn][1], TruckStart[randn][2], TruckStart[randn][3], -1, -1, -1);
                    
PutPlayerInVehicle(playeridVJob[playerid], 0);
                    
IsWorking[playerid] = 1;
                    
SetDestination(playerid2502.9927,2778.0164,10.8203);
                    
ShowJobBox(playerid);
                    
UpdateJobBox(playerid);
                
                }
            }
        
        }
    }
    return 
1;

any ideas?
Reply
#2

'It doesn't work' what's that supposed to mean? HOW does it NOT work? errors compiling? errors in-game??
Reply
#3

no errors compiling, no erros in game.

it just works everywhere on the map and gives me a random job.

i tried putting
PHP код:
if(!PlayerToPoint(3.0, .... return SCMyou are not near a job 
and i would always get You are not near a job message even if im near a job.
Reply
#4

Try this.

Код:
forward GetJobID(playerid);
public GetJobID(playerid)
{
       for(new j = 1; j < MAX_JOBS; j++)  
       {
               if(IsPlayerInRangeOfPoint(playerid, 3, JobInfo[j][jPosX], JobInfo[j][jPosY], JobInfo[j][jPosZ])) return j;
       }
       return 0;
}

YCMD:work(playerid, params[], help) 
{ 
    if(IsWorking[playerid] == 1) return SendClientMessage(playerid, COLOR_WHITE, "Already working."); 
    if(GetJobID(playerid) == 0) return SendClientMessage(playerid, COLOR_WHITE, "You need to be near a job pickup");
    else
    {
           new j = GetJobID(playerid);
           switch(j) 
            { 
                case 1: 
                { 

                } 
                case 2: 
                { 
                    PWarehouseCP[playerid] = 2; 
                    PWarehouseCurrent[playerid] = 0; 
                    IsWorking[playerid] = 1; 
                    new randn = random(sizeof(WarehouseExteriorCP)); 
                    SetPlayerCheckpoint(playerid, WarehouseExteriorCP[randn][0], WarehouseExteriorCP[randn][1], WarehouseExteriorCP[randn][2], 1.0); 
                    SetDestination(playerid, WarehouseExteriorCP[randn][0], WarehouseExteriorCP[randn][1], WarehouseExteriorCP[randn][2]); 
                } 
                case 3: 
                { 

                } 
                case 4: 
                { 

                } 
                case 5: 
                { 
                 
                    ShowPlayerDialog(playerid, DIALOG_TRUCKER, DIALOG_STYLE_TABLIST_HEADERS, "Choose the transport type", "Type\tLegal/Illegal\tAvailable routes\tReward\nFood\tLegal\t25\t{4AE87D}${FFFFFF}\nElectronics\tLegal\t25\t{4AE87D}${FFFFFF}\nGas/Petrol\tLegal\t15\t{4AE87D}${FFFFFF}\nCar Theft\tIllegal\t2\t{4AE87D}${FFFFFF} + {F37138}special rewards{FFFFFF}", "Choose", "Cancel"); 
                    new randn = random(sizeof(TruckStart)); 
                    VJob[playerid] = CreateVehicle(515, TruckStart[randn][0], TruckStart[randn][1], TruckStart[randn][2], TruckStart[randn][3], -1, -1, -1); 
                    PutPlayerInVehicle(playerid, VJob[playerid], 0); 
                    IsWorking[playerid] = 1; 
                    SetDestination(playerid, 2502.9927,2778.0164,10.8203); 
                    ShowJobBox(playerid); 
                    UpdateJobBox(playerid); 
                 
                } 
            } 
    }

    return 1;
}
Hope i helped u.
Reply
#5

not working
Reply
#6

Show us your JobInfo structure and where you add those coordinates (jPosX, jPosY...). Maybe they're wrong?
Try increasing the distance from 3.0 to 5.0 temporarily. When you're near the place where you can take the job write /save (this data is saved in your GTA SA User Files folder, which is with your SA:MP screenshots). Compare this data to jPoX, etc. if you are actually at the place to pick up the job.

After using what kingmk suggested, what changed? Does it still give you a random job and anywhere on the map or does it say you're not in range?
Reply
#7

Try this for debbugging.

Код:
CMD:gotojob(playerid, params[])
{
       new id;
       if(sscanf(params, "d", id)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /gotojob [JobID]");
       if(id <= 0) return 0;
       SetPlayerPos(playerid, JobInfo[id][jPosX], JobInfo[id][jPosY], JobInfo[id][jPosZ]);
       return 1;
}
After u use this command type /work
Reply
#8

The gotojob cmd works,also getjob works..still this doesn t work
Reply
#9

Quote:
Originally Posted by PepsiCola23
Посмотреть сообщение
The gotojob cmd works,also getjob works..still this doesn t work
I don't undesrstood what is not working.

You have only 2 jobs on server: jobID 2 and jobiID 5.

If u will be on onther jobID, then this will not work, cuz the case 1,3,4 are EMPTY;

If u wanna return a maeesage will be something like that

Код:
switch(j)
{
     case 2:
     {
            PWarehouseCP[playerid] = 2; 
            PWarehouseCurrent[playerid] = 0; 
            IsWorking[playerid] = 1; 
            new randn = random(sizeof(WarehouseExteriorCP)); 
            SetPlayerCheckpoint(playerid, WarehouseExteriorCP[randn][0], WarehouseExteriorCP[randn][1], WarehouseExteriorCP[randn][2], 1.0); 
            SetDestination(playerid, WarehouseExteriorCP[randn][0], WarehouseExteriorCP[randn][1], WarehouseExteriorCP[randn][2]); 
     }
     case 5:
     {
           ShowPlayerDialog(playerid, DIALOG_TRUCKER, DIALOG_STYLE_TABLIST_HEADERS, "Choose the transport type", "Type\tLegal/Illegal\tAvailable routes\tReward\nFood\tLegal\t25\t{4AE87D}${FFFFFF}\nElectronics\tLegal\t25\t{4AE87D}${FFFFFF}\nGas/Petrol\tLegal\t15\t{4AE87D}${FFFFFF}\nCar Theft\tIllegal\t2\t{4AE87D}${FFFFFF} + {F37138}special rewards{FFFFFF}", "Choose", "Cancel"); 
           new randn = random(sizeof(TruckStart)); 
           VJob[playerid] = CreateVehicle(515, TruckStart[randn][0], TruckStart[randn][1], TruckStart[randn][2], TruckStart[randn][3], -1, -1, -1); 
           PutPlayerInVehicle(playerid, VJob[playerid], 0); 
           IsWorking[playerid] = 1; 
           SetDestination(playerid, 2502.9927,2778.0164,10.8203); 
           ShowJobBox(playerid); 
           UpdateJobBox(playerid); 
     }
     default: return SendClientMessage(playerid, -1, "This job it's not finish yet.");
}
Reply
#10

When im at job 2 and 5 positions, type work nothing happens
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)