Checkpoints.. [HELP]
#1

My friend (Admantis) made this job script for our script, I do know some scripting myself but I don't know why the checkpoints won't work sometimes ( like when you fail or when you pass )

pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
    new newcar = GetPlayerVehicleID(playerid);
    if (GetPVarInt(playerid, "QuarryStatus") == 1)
    {
        switch(random(100))
        {
            case 0..49:
            {
                SendClientMessage(playerid, COLOR_WHITE, "[INFO]: You haven't found any diamonds, try digging in another point!");
                switch(random(5))
                {
                    case 0: SetPlayerCheckpoint(playerid, 681.9300,822.4588,-27.2878, 10);
                    case 1: SetPlayerCheckpoint(playerid, 694.9890,842.5770,-27.4996, 10);
                    case 2: SetPlayerCheckpoint(playerid, 718.9802,923.3948,-19.0700, 10);
                    case 3: SetPlayerCheckpoint(playerid, 691.6136,738.6771,-5.8858 , 10);
                    case 4: SetPlayerCheckpoint(playerid, 504.4493,795.1776,-22.2935, 10);
                }
            }
            case 50..99:
            {
                new diamondcount = 2 + random(15);
                SetPVarInt(playerid, "TempDiamonds", diamondcount);
                SetPVarInt(playerid, "QuarryStatus", 2);
                SetPlayerCheckpoint(playerid, 586.0655,870.0052,-42.4973, 3);
                new szstring[128];
                format(szstring, 128, "[INFO]: You digged and found %d diamonds. Return to the base and deliver them.", diamondcount);
                SendClientMessage(playerid, COLOR_WHITE, szstring);
            }
        }
    }
    if (GetPVarInt(playerid, "QuarryStatus") == 2)
    {
        SetPVarInt(playerid, "QuarryStatus", 0);
        SetPVarInt(playerid, "TempDiamonds", 0);
        DisablePlayerCheckpoint(playerid);
        new togive, szs[128], vtr;
        togive = (GetPVarInt(playerid, "TempDiamonds") * 100);
        format(szs, 128, "[INFO]: You have sold %d diamonds for {00FF00}$%d, good job!", GetPVarInt(playerid, "TempDiamonds"), togive);
        GivePlayerPCash(playerid, togive);
        vtr = GetNearestVehicle(playerid, 25);
        SetVehicleToRespawn(vtr);
    }
Reply
#2

Maybe the checkpoint problem it's not from here. But look at here:
PHP код:
 if (GetPVarInt(playerid"QuarryStatus") == 2)
    {
        
SetPVarInt(playerid"QuarryStatus"0);
        
SetPVarInt(playerid"TempDiamonds"0);
        
DisablePlayerCheckpoint(playerid);
        new 
togiveszs[128], vtr;
        
togive = (GetPVarInt(playerid"TempDiamonds") * 100);
        
format(szs128"[INFO]: You have sold %d diamonds for {00FF00}$%d, good job!"GetPVarInt(playerid"TempDiamonds"), togive);
        
GivePlayerPCash(playeridtogive);
        
vtr GetNearestVehicle(playerid25);
        
SetVehicleToRespawn(vtr);
    } 
First, you set TempDiamons to 0 ( SetPVarInt(playerid, "TempDiamonds", 0); ), then, in variable togive you multiply TempDiamons with 100, which everytime will be 0 ( togive = (GetPVarInt(playerid, "TempDiamonds") * 100); ).

pawn Код:
SetPVarInt(playerid, "TempDiamonds", 0); /* TempDiamons = 0; */
togive = (GetPVarInt(playerid, "TempDiamonds") * 100); /* togive = 0 * 100 = 0*/
Reply
#3

Add 'else'

pawn Код:
else if (GetPVarInt(playerid, "QuarryStatus") == 2)
Reply
#4

Quote:
Originally Posted by MoroDan
Посмотреть сообщение
Maybe the checkpoint problem it's not from here. But look at here:
PHP код:
 if (GetPVarInt(playerid"QuarryStatus") == 2)
    {
        
SetPVarInt(playerid"QuarryStatus"0);
        
SetPVarInt(playerid"TempDiamonds"0);
        
DisablePlayerCheckpoint(playerid);
        new 
togiveszs[128], vtr;
        
togive = (GetPVarInt(playerid"TempDiamonds") * 100);
        
format(szs128"[INFO]: You have sold %d diamonds for {00FF00}$%d, good job!"GetPVarInt(playerid"TempDiamonds"), togive);
        
GivePlayerPCash(playeridtogive);
        
vtr GetNearestVehicle(playerid25);
        
SetVehicleToRespawn(vtr);
    } 
First, you set TempDiamons to 0 ( SetPVarInt(playerid, "TempDiamonds", 0); ), then, in variable togive you multiply TempDiamons with 100, which everytime will be 0 ( togive = (GetPVarInt(playerid, "TempDiamonds") * 100); ).

pawn Код:
SetPVarInt(playerid, "TempDiamonds", 0); /* TempDiamons = 0; */
togive = (GetPVarInt(playerid, "TempDiamonds") * 100); /* togive = 0 * 100 = 0*/
Okay thanks, but now the second one. Why does the checkpoint doesn't come up when you fail and don't find any diamonds?
Reply
#5

Try it now:

PHP код:
public OnPlayerEnterCheckpoint(playerid)
{
    new 
newcar GetPlayerVehicleID(playerid);
    if (
GetPVarInt(playerid"QuarryStatus") == 1)
    {
        switch(
random(100))
        {
            case 
0..49:
            {
                
DisablePlayerCheckpoint(playerid);
                
SendClientMessage(playeridCOLOR_WHITE"[INFO]: You haven't found any diamonds, try digging in another point!");
                switch(
random(5))
                {
                    case 
0SetPlayerCheckpoint(playerid681.9300,822.4588,-27.287810);
                    case 
1SetPlayerCheckpoint(playerid694.9890,842.5770,-27.499610);
                    case 
2SetPlayerCheckpoint(playerid718.9802,923.3948,-19.070010);
                    case 
3SetPlayerCheckpoint(playerid691.6136,738.6771,-5.8858 10);
                    case 
4SetPlayerCheckpoint(playerid504.4493,795.1776,-22.293510);
                }
            }
            case 
50..99:
            {
                new 
diamondcount random(15);
                
SetPVarInt(playerid"TempDiamonds"diamondcount);
                
SetPVarInt(playerid"QuarryStatus"2);
                
SetPlayerCheckpoint(playerid586.0655,870.0052,-42.49733);
                new 
szstring[128];
                
format(szstring128"[INFO]: You digged and found %d diamonds. Return to the base and deliver them."diamondcount);
                
SendClientMessage(playeridCOLOR_WHITEszstring);
            }
        }
    }
    if (
GetPVarInt(playerid"QuarryStatus") == 2)
    {
        
SetPVarInt(playerid"QuarryStatus"0);
        
SetPVarInt(playerid"TempDiamonds"0);
        
DisablePlayerCheckpoint(playerid);
        new 
togiveszs[128], vtr;
        
togive = (GetPVarInt(playerid"TempDiamonds") * 100);
        
format(szs128"[INFO]: You have sold %d diamonds for {00FF00}$%d, good job!"GetPVarInt(playerid"TempDiamonds"), togive);
        
GivePlayerPCash(playeridtogive);
        
vtr GetNearestVehicle(playerid25);
        
SetVehicleToRespawn(vtr);
    } 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)