Job Problem
#1

When i start a job (go through checkpoints for money) and quit while it is active, then when i reconnect and i start the job again, i go through the first marker and get payed (I'm supposed to go through like 8, not 1). Then again i start the job, it still gives the money on the first checkpoint.

Defining the checkpoint checker (If a player goes through the first checkpoint, pokupipostu[playerid] = 2;)
Код:
new pokupipostu[MAX_PLAYERS];
When the player connects, pokupipostu[playerid] = 0;
Код:
public OnPlayerConnect(playerid)
{
	pokupipostu[playerid] = 0;
        return 1;
}
When the player disconnects, pokupipostu[playerid] = 0;
Код:
public OnPlayerDisconnect(playerid)
{
        pokupipostu[playerid] = 0;
        return 1;
}
If a player is in range of a checkpoint, pokupipostu[playerid] = some number;
Код:
if(IsPlayerInRangeOfPoint(playerid, 3.0, -2358.3467,803.3227,38.3803) && pokupipostu[playerid] == 1 && IsPlayerInVehicle(playerid, pv6) || IsPlayerInVehicle(playerid, pv7))
	{
	    pokupipostu[playerid] = 2;
	    SetPlayerCheckpoint(playerid, -2224.3804,804.1550,49.2969, 3.0);
	}
	if(IsPlayerInRangeOfPoint(playerid, 3.0, -2224.3804,804.1550,49.2969) && pokupipostu[playerid] == 2 && IsPlayerInVehicle(playerid, pv6) || IsPlayerInVehicle(playerid, pv7))
	{
	    pokupipostu[playerid] = 3;
	    SetPlayerCheckpoint(playerid, -2151.5386,786.5508,69.4141, 3.0);
	}
	if(IsPlayerInRangeOfPoint(playerid, 3.0, -2151.5386,786.5508,69.4141) && pokupipostu[playerid] == 3 && IsPlayerInVehicle(playerid, pv6) || IsPlayerInVehicle(playerid, pv7))
	{
	    pokupipostu[playerid] = 4;
	    SetPlayerCheckpoint(playerid, -2151.6677,644.7795,52.3672, 3.0);
	}
	if(IsPlayerInRangeOfPoint(playerid, 3.0, -2151.6677,644.7795,52.3672) && pokupipostu[playerid] == 4 && IsPlayerInVehicle(playerid, pv6) || IsPlayerInVehicle(playerid, pv7))
	{
	    pokupipostu[playerid] = 5;
	    SetPlayerCheckpoint(playerid, -2185.7598,573.2388,35.0156, 3.0);
	}
	if(IsPlayerInRangeOfPoint(playerid, 3.0, -2185.7598,573.2388,35.0156) && pokupipostu[playerid] == 5 && IsPlayerInVehicle(playerid, pv6) || IsPlayerInVehicle(playerid, pv7))
	{
	    pokupipostu[playerid] = 6;
	    SetPlayerCheckpoint(playerid, -2246.9546,620.5477,45.3104, 3.0);
	}
	if(IsPlayerInRangeOfPoint(playerid, 3.0, -2246.9546,620.5477,45.3104) && pokupipostu[playerid] == 6 && IsPlayerInVehicle(playerid, pv6) || IsPlayerInVehicle(playerid, pv7))
	{
	    pokupipostu[playerid] = 7;
	    SetPlayerCheckpoint(playerid, -2321.4087,674.2640,42.0596, 3.0);
	}
	if(IsPlayerInRangeOfPoint(playerid, 3.0, -2321.4087,674.2640,42.0596) && pokupipostu[playerid] == 7 && IsPlayerInVehicle(playerid, pv6) || IsPlayerInVehicle(playerid, pv7))
	{
	    pokupipostu[playerid] = 8;
	    SetPlayerCheckpoint(playerid, -2468.9990,798.5485,35.1797, 3.0);
	}
	if(IsPlayerInRangeOfPoint(playerid, 3.0, -2468.9990,798.5485,35.1797) && pokupipostu[playerid] == 8 && IsPlayerInVehicle(playerid, pv6) || IsPlayerInVehicle(playerid, pv7))
	{
        pokupipostu[playerid] = 0;
	    SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}[IN:RP] {FFFFFF}Uspesno ste pokupili postu, pa ste dobili $100 i 1 EXP.");
		PlayerInfo[playerid][pExp] += 1;
		GivePlayerMoney(playerid, 100);
		DisablePlayerCheckpoint(playerid);
	}
        return 1;
}
Command to start the job (first checks if the player has a job as 'POSTAR' in my language, then does the command).
Код:
CMD:pokupipostu(playerid, params[])
{
    if(PlayerInfo[playerid][pPosao] == 1)
	{
		SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}[IN:RP] {FFFFFF}Uspesno ste poceli da pokupljate postu.");
		SetPlayerCheckpoint(playerid, -2358.3467, 803.3227, 38.3803, 3.0);
		pokupipostu[playerid] = 1;
	}
	else
	{
	    SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}ERROR: {FFFFFF}Morate biti zaposleni kao POSTAR!");
	}
	return 1;
}
Reply
#2

You should process like this.
There a way more easy to do.
Add a variable in your like ActiveJob[playerid] = 1; when you do the command.
Use
PHP код:
public OnPlayerEnterCheckpoint(playerid)
if(
Activejob[playerid] == 1)
{
...
Activejob[playerid] = 2;
... 
}
if(
Activejob[playerid] == 2)
... 
You get it?
Reply
#3

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
You should process like this.
There a way more easy to do.
Add a variable in your like ActiveJob[playerid] = 1; when you do the command.
Use
PHP код:
public OnPlayerEnterCheckpoint(playerid)
if(
Activejob[playerid] == 1)
{
...
Activejob[playerid] = 2;
... 
}
if(
Activejob[playerid] == 2)
... 
You get it?
Umm, i think you misunderstood me. There are multiple jobs which require the player to be in a specific vehicle. Also, i already have Activejob defined. It's raznesipostu1[playerid], raznesipostu2[playerid] and pokupipostu[playerid].

Example in the code:
Код:
if(IsPlayerInRangeOfPoint(playerid, 3.0, -2541.7466, 896.7819, 64.9844) && raznesipostu1[playerid] == 7 && IsPlayerInVehicle(playerid, pv1) || IsPlayerInVehicle(playerid, pv2) || IsPlayerInVehicle(playerid, pv3) || IsPlayerInVehicle(playerid, pv4) || IsPlayerInVehicle(playerid, pv5))
	{
	    raznesipostu1[playerid] = 8;
	    SetPlayerCheckpoint(playerid, -2467.7964,797.8687,35.1719, 3.0);
	}
Reply
#4

You misunderstood me.
I talking about using public OnPlayerEnterCheckpoint(playerid) instead of IsPlayerInRangeOfPoint
This is more efficient.
Reply
#5

What did you think was i using

Код:
public OnPlayerEnterCheckpoint(playerid)
{
	if(IsPlayerInRangeOfPoint(playerid, 3.0, -2358.3467,803.3227,38.3803) && pokupipostu[playerid] == 1 && IsPlayerInVehicle(playerid, pv6) || IsPlayerInVehicle(playerid, pv7))
	{
	    pokupipostu[playerid] = 2;
	    SetPlayerCheckpoint(playerid, -2224.3804,804.1550,49.2969, 3.0);
	}
	if(IsPlayerInRangeOfPoint(playerid, 3.0, -2224.3804,804.1550,49.2969) && pokupipostu[playerid] == 2 && IsPlayerInVehicle(playerid, pv6) || IsPlayerInVehicle(playerid, pv7))
	{
	    pokupipostu[playerid] = 3;
	    SetPlayerCheckpoint(playerid, -2151.5386,786.5508,69.4141, 3.0);
	}
	if(IsPlayerInRangeOfPoint(playerid, 3.0, -2151.5386,786.5508,69.4141) && pokupipostu[playerid] == 3 && IsPlayerInVehicle(playerid, pv6) || IsPlayerInVehicle(playerid, pv7))
	{
	    pokupipostu[playerid] = 4;
	    SetPlayerCheckpoint(playerid, -2151.6677,644.7795,52.3672, 3.0);
	}
	if(IsPlayerInRangeOfPoint(playerid, 3.0, -2151.6677,644.7795,52.3672) && pokupipostu[playerid] == 4 && IsPlayerInVehicle(playerid, pv6) || IsPlayerInVehicle(playerid, pv7))
	{
	    pokupipostu[playerid] = 5;
	    SetPlayerCheckpoint(playerid, -2185.7598,573.2388,35.0156, 3.0);
	}
	if(IsPlayerInRangeOfPoint(playerid, 3.0, -2185.7598,573.2388,35.0156) && pokupipostu[playerid] == 5 && IsPlayerInVehicle(playerid, pv6) || IsPlayerInVehicle(playerid, pv7))
	{
	    pokupipostu[playerid] = 6;
	    SetPlayerCheckpoint(playerid, -2246.9546,620.5477,45.3104, 3.0);
	}
	if(IsPlayerInRangeOfPoint(playerid, 3.0, -2246.9546,620.5477,45.3104) && pokupipostu[playerid] == 6 && IsPlayerInVehicle(playerid, pv6) || IsPlayerInVehicle(playerid, pv7))
	{
	    pokupipostu[playerid] = 7;
	    SetPlayerCheckpoint(playerid, -2321.4087,674.2640,42.0596, 3.0);
	}
	if(IsPlayerInRangeOfPoint(playerid, 3.0, -2321.4087,674.2640,42.0596) && pokupipostu[playerid] == 7 && IsPlayerInVehicle(playerid, pv6) || IsPlayerInVehicle(playerid, pv7))
	{
	    pokupipostu[playerid] = 8;
	    SetPlayerCheckpoint(playerid, -2468.9990,798.5485,35.1797, 3.0);
	}
	if(IsPlayerInRangeOfPoint(playerid, 3.0, -2468.9990,798.5485,35.1797) && pokupipostu[playerid] == 8 && IsPlayerInVehicle(playerid, pv6) || IsPlayerInVehicle(playerid, pv7))
	{
        pokupipostu[playerid] = 0;
	    SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}[IN:RP] {FFFFFF}Uspesno ste pokupili postu, pa ste dobili $100 i 1 EXP.");
		PlayerInfo[playerid][pExp] += 1;
		GivePlayerMoney(playerid, 100);
		DisablePlayerCheckpoint(playerid);
	}
	return 1;
}
Reply
#6

So why are you using IsPlayerInRangeOfPoint(playerid, 3.0, -2358.3467,803.3227,38.3803) ?
There is no sence. Remove it, you don't need it.
Reply
#7

When a player enters a checkpoint, it checks if he entered the specific checkpoint, checks if raznesipostu[playerid] == 1 and checks if you're in the right vehicle.

This is pointless, i need help with fixing the problem. Not help with optimizing the code. Now, can you help me or not?

raznesipostu[playerid] function is like ActiveJob[playerid], just a different name.
Reply
#8

Hello!

Try this:
PHP код:
public OnPlayerEnterCheckpoint(playerid)
{
    
DisablePlayerCheckpoint(playerid);
    if(
IsPlayerInVehicle(playerid,pv6) || IsPlayerInVehicle(playerid,pv7))
    {
        switch(
pokupipostu[playerid])
        {
            case 
1:{
                if(!
IsPlayerInRangeOfPoint(playerid3.0, -2358.3467,803.3227,38.3803))return 1;
                
pokupipostu[playerid] = 2;
                
SetPlayerCheckpoint(playerid, -2224.3804,804.1550,49.29693.0);
                return 
1;
            }
            case 
2:{
                if(!
IsPlayerInRangeOfPoint(playerid3.0, -2224.3804,804.1550,49.2969))return 1;
                
pokupipostu[playerid] = 3;
                
SetPlayerCheckpoint(playerid, -2151.5386,786.5508,69.41413.0);
                return 
1;
            }
            case 
3:{
                if(!
IsPlayerInRangeOfPoint(playerid3.0, -2151.5386,786.5508,69.4141))return 1;
                
pokupipostu[playerid] = 4;
                
SetPlayerCheckpoint(playerid, -2151.6677,644.7795,52.36723.0);
                return 
1;
            }
            case 
4:{
                if(!
IsPlayerInRangeOfPoint(playerid3.0, -2151.6677,644.7795,52.3672))return 1;
                
pokupipostu[playerid] = 5;
                
SetPlayerCheckpoint(playerid, -2185.7598,573.2388,35.01563.0);
                return 
1;
            }
            case 
5:{
                if(!
IsPlayerInRangeOfPoint(playerid3.0, -2185.7598,573.2388,35.0156))return 1;
                
pokupipostu[playerid] = 6;
                
SetPlayerCheckpoint(playerid, -2246.9546,620.5477,45.31043.0);
                return 
1;
            }
            case 
6:{
                if(!
IsPlayerInRangeOfPoint(playerid3.0, -2246.9546,620.5477,45.3104))return 1;
                
pokupipostu[playerid] = 7;
                
SetPlayerCheckpoint(playerid, -2321.4087,674.2640,42.05963.0);
                return 
1;
            }
            case 
7:{
                if(!
IsPlayerInRangeOfPoint(playerid3.0, -2321.4087,674.2640,42.0596))return 1;
                
pokupipostu[playerid] = 8;
                
SetPlayerCheckpoint(playerid, -2468.9990,798.5485,35.17973.0);
                return 
1;
            }
            case 
8:{
                if(!
IsPlayerInRangeOfPoint(playerid3.0, -2468.9990,798.5485,35.1797))return 1;
                
pokupipostu[playerid] = 0;
                
SendClientMessage(playerid0xFFFFFFFF"{FF0000}[IN:RP] {FFFFFF}Uspesno ste pokupili postu, pa ste dobili $100 i 1 EXP.");
                
PlayerInfo[playerid][pExp] += 1;
                
GivePlayerMoney(playerid100);
                
DisablePlayerCheckpoint(playerid);
                return 
1;
            }
        }
    }
    return 
1;

I changed your if clause to a switch clause.
Reply
#9

Код:
if(!IsPlayerInRangeOfPoint(playerid, 3.0, -2151.5386,786.5508,69.4141))return 1;
C:\Users\notshowing\Desktop\notshowing\gamemodes\n otshowing.pwn(476) : error 079: inconsistent return types (array & non-array)
Reply
#10

I can compile this perfectly. Can you show us the lines around 476 (476+10 and 476-10)
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)