SA-MP Forums Archive
streamer - DynamicCP - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: streamer - DynamicCP (/showthread.php?tid=665033)



streamer - DynamicCP - Cauezin - 19.03.2019

Hello,

I'm doing a simple delivery system with dynamic checkpoints, using the include "streamer", but it's not working properly.
The right thing would be to enter the checkpoint and start the job, destroy it, create another checkpoint, and when he entered that new checkpoint, he would finish the job.
But he's just starting out and finishing work at the same checkpoint instantly.

What am I doing wrong?






The code:


PHP код:

                    CheckCarregar_TransportadorRefC
[playerid] = CreateDynamicCP(-1005.3510,-676.9293,32.00787.0, -1, -1playeridSTREAMER_CP_SD, -10);
                    
SetPlayerMapIcon(playerid0, -1005.3510,-676.9293,32.007800xFF0000AA0); 
PHP код:

public OnPlayerEnterDynamicCP(playeridcheckpointid)
{
    if(
checkpointid == CheckCarregar_TransportadorRefC[playerid])
    {
        if(
IsPlayerInVehicleJob_01(playerid))
        {
            if(
IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)))
            {
                
DestroyDynamicCP(CheckCarregar_TransportadorRefC[playerid]);
                
RemovePlayerMapIcon(playerid0);
                
SendClientMessage(playerid, -1"loading.");
                
CheckDes_TransportadorRefC[playerid] = CreateDynamicCP(264.9304,1388.5432,10.58597.0, -1, -1playeridSTREAMER_CP_SD, -10);
                
SetPlayerMapIcon(playerid0264.9304,1388.5432,10.585900xFF0000AA0);
            } else 
SendClientMessage(playerid, -1"Vocк nгo estб com o trailer da sua profissгo engatado");
        } else return 
SendClientMessage(playerid, -1"Esse nгo й seu veiculo de trabalho");
    }
    if(
checkpointid == CheckDes_TransportadorRefC[playerid])
    {
        if(
IsPlayerInVehicleJob_01(playerid))
        {
            if(
IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)))
            {
                
DestroyDynamicCP(CheckDes_TransportadorRefC[playerid]);
                
Player[playerid][pTrabalhando] = false;
                
SendClientMessage(playerid, -1"finished.");
                
RemovePlayerMapIcon(playerid0);
            } else 
SendClientMessage(playerid, -1"Vocк nгo estб com o trailer da sua profissгo engatado");
        } else return 
SendClientMessage(playerid, -1"Esse nгo й seu veiculo de trabalho");
    }
    return 
1;

Sorry for my bad English, this is not my language forum, but I came to do this post here because the creator of the streamer is from that area.


Re: streamer - DynamicCP - justinnater - 21.03.2019

First time you create the CP, you store the returned id from the function CreateDynamicCP into the variable 'CheckCarregar_TransportadorRefC[playerid]'
Lets just assume it is the first CP since server start created and stored into your variable.
Your variable 'CheckCarregar_TransportadorRefC[playerid]' is now containing the number '1'.

As when you create a second CP and store it in the other variable, the number would be 2.
BUT... You are deleting the first CP before creating the second CP, meaning that you just freed up slot 1 from the CP and the next CP created will be 1, meaning you are now getting a conflict on these two lines because they are equal:
Quote:

if(checkpointid == CheckCarregar_TransportadorRefC[playerid])
if(checkpointid == CheckDes_TransportadorRefC[playerid])

because you are not ending your first code within the checker from 'if(checkpointid == CheckCarregar_TransportadorRefC[playerid]) ' with a 'return' this problem happens.

add a return 1; in each statement

Set the variable to 0 when deleted with destroydynamiccp


Re: streamer - DynamicCP - Cauezin - 21.03.2019

Quote:
Originally Posted by justinnater
Посмотреть сообщение
First time you create the CP, you store the returned id from the function CreateDynamicCP into the variable 'CheckCarregar_TransportadorRefC[playerid]'
Lets just assume it is the first CP since server start created and stored into your variable.
Your variable 'CheckCarregar_TransportadorRefC[playerid]' is now containing the number '1'.

As when you create a second CP and store it in the other variable, the number would be 2.
BUT... You are deleting the first CP before creating the second CP, meaning that you just freed up slot 1 from the CP and the next CP created will be 1, meaning you are now getting a conflict on these two lines because they are equal:


because you are not ending your first code within the checker from 'if(checkpointid == CheckCarregar_TransportadorRefC[playerid]) ' with a 'return' this problem happens.

add a return 1; in each statement

Set the variable to 0 when deleted with destroydynamiccp
Finally someone told me a solution that really worked, thank you very much.


Re: streamer - DynamicCP - antixgaming - 22.03.2019

There aren't a lot of solutions in this thread though...


Re: streamer - DynamicCP - Pottus - 23.03.2019

Quote:
Originally Posted by justinnater
Посмотреть сообщение
First time you create the CP, you store the returned id from the function CreateDynamicCP into the variable 'CheckCarregar_TransportadorRefC[playerid]'
Lets just assume it is the first CP since server start created and stored into your variable.
Your variable 'CheckCarregar_TransportadorRefC[playerid]' is now containing the number '1'.

As when you create a second CP and store it in the other variable, the number would be 2.
BUT... You are deleting the first CP before creating the second CP, meaning that you just freed up slot 1 from the CP and the next CP created will be 1, meaning you are now getting a conflict on these two lines because they are equal:


because you are not ending your first code within the checker from 'if(checkpointid == CheckCarregar_TransportadorRefC[playerid]) ' with a 'return' this problem happens.

add a return 1; in each statement

Set the variable to 0 when deleted with destroydynamiccp
He shouldn't have more than one return anyways. Using return is a poor solution when it should be else if. Also those variables should be set to -1 to indicate invalid.

Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    if(checkpointid == CheckCarregar_TransportadorRefC[playerid])
    {
        if(IsPlayerInVehicleJob_01(playerid))
        {
            if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)))
            {
                DestroyDynamicCP(CheckCarregar_TransportadorRefC[playerid]);
				CheckCarregar_TransportadorRefC[playerid] = -1;
                RemovePlayerMapIcon(playerid, 0);
                SendClientMessage(playerid, -1, "loading.");

                CheckDes_TransportadorRefC[playerid] = CreateDynamicCP(264.9304,1388.5432,10.5859, 7.0, -1, -1, playerid, STREAMER_CP_SD, -1, 0);
                SetPlayerMapIcon(playerid, 0, 264.9304,1388.5432,10.5859, 0, 0xFF0000AA, 0);

            } else SendClientMessage(playerid, -1, "Vocк nгo estб com o trailer da sua profissгo engatado");
        } else SendClientMessage(playerid, -1, "Esse nгo й seu veiculo de trabalho");
    }
    else if(checkpointid == CheckDes_TransportadorRefC[playerid])
    {
        if(IsPlayerInVehicleJob_01(playerid))
        {
            if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)))
            {
                DestroyDynamicCP(CheckDes_TransportadorRefC[playerid]);
                CheckDes_TransportadorRefC[playerid] = -1;
                Player[playerid][pTrabalhando] = false;
                SendClientMessage(playerid, -1, "finished.");
                RemovePlayerMapIcon(playerid, 0);

            } else SendClientMessage(playerid, -1, "Vocк nгo estб com o trailer da sua profissгo engatado");
        } else SendClientMessage(playerid, -1, "Esse nгo й seu veiculo de trabalho");
    }
    return 1;
}