DynamicCP
#1

Sorted. TY
Reply
#2

Use SetTimerEx if you're basing the timer on a player.
https://sampwiki.blast.hk/wiki/SetTimerEx
Reply
#3

Quote:
Originally Posted by CalvinC
Посмотреть сообщение
Use SetTimerEx if you're basing the timer on a player.
https://sampwiki.blast.hk/wiki/SetTimerEx
Thanks I changed them, but that doesn't solve the issue i'm having

StartDropOff if it makes any difference.
pawn Код:
public StartDropOff(playerid)
{
    SendClientMessage(playerid, -1,"Creating Drop off CP");
    DestroyDynamicCP(PickupCP[playerid]);
    CreateTruckDropoff(playerid);
    return 1;
}
Reply
#4

Can you show your "TruckingCompleted" public?
Reply
#5

I dont think it's the issue here since it's not even called, but here you go:
pawn Код:
public TruckingCompleted(playerid)
{
    new string[126];
    new random_money = DropLoc[playerid][minPay]+random(DropLoc[playerid][maxPay]); //Random money based on minPay and maxPay in the array.
       
    GameTextForPlayer(playerid, string, 3000, 3);
    format(string, sizeof(string), "Truck Delivery Completed~n~~g~%s$", random_money);
    GivePlayerMoney(playerid, random_money);

    DestroyDynamicCP(DropoffCP[playerid]); //Destroys the checkpoint once delivery is completed.
    return 1;
}
Reply
#6

Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
It looks like the old variable for storing the pick up checkpoint is not being reset and because that checkpoint is destroyed, the next available ID just so happens to be that same ID, resulting in the pick up and drop off variables containing the same value.

The best practice to prevent this is: whenever you call a Destroy* function on a variable, reset that variable to an invalid value.

*This goes for anything: vehicles (DestroyVehicle(var), var = INVALID_VEHICLE_ID), objects (DestroyObject(var), var = INVALID_OBJECT_ID), etc...

In situations like this, it's always best to print out your variables so you can actually see what values they are storing then check them against what you expect the code to do. The expectation here is that in OnPlayerEnterDynamicCP, PickupCP[playerid] does not contain the same value as DropoffCP[playerid] because if that's so, then the pick up code gets run first (and blocks the other code since there's a return).

Hope that helped! If not, print out the variables around the code and post your findings.
I kinda understood what you just said but where would I use invalid_object_id? I don't see any other scripts using it so why would it be necessary here? :P
Reply
#7

He didn't tell you to use it, he just gave an example that you should always use INVALID_X_ID when destroying something.
Reply
#8

Quote:
Originally Posted by CalvinC
Посмотреть сообщение
He didn't tell you to use it, he just gave an example that you should always use INVALID_X_ID when destroying something.
DestroyDynamicCP(DropoffCP[playerid]), DropoffCP[playerid] = INVALID_CHECKPOINT_ID;

Works!, thanks guys.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)