SA-MP Forums Archive
If you exit a vehicle, it cancels the job. (need help) - 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: If you exit a vehicle, it cancels the job. (need help) (/showthread.php?tid=282659)



If you exit a vehicle, it cancels the job. (need help) - rangerxxll - 12.09.2011

Hello, I'm trying to improve my filterscript, and I'm trying to make it so if you exit the vehicle, it will remove the checkpoint and say "You're delivery was canceled due to exiting the vehicle"

So far I have:

pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    if((simplejobrunning) == 1)
    {
        simplejobrunning = 0;
        SendClientMessage(playerid, COLOR_RED, "You're job was canceled due to exiting the Vehicle");

    }else if((simplejobrunning) == 0){

       
 }
}
I already have
pawn Код:
new simplejobrunning = 0;
What am I doing wrong?


Re: If you exit a vehicle, it cancels the job. (need help) - Dr - 12.09.2011

pawn Код:
DisablePlayerCheckpoint(playerid);
Also when you created the "simplejobrunning" variable do this instead:

pawn Код:
simplejobrunning[MAX_PLAYERS];
Then change the code to this:
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    if(simplejobrunning[playerid] == 1)
    {
        simplejobrunning[playerid] = 0;
        SendClientMessage(playerid, COLOR_RED, "You're job was canceled due to exiting the Vehicle");
        DisablePlayerCheckpoint(playerid);
    }
    return 1;
}
The else is not needed.


Re: If you exit a vehicle, it cancels the job. (need help) - =WoR=G4M3Ov3r - 12.09.2011

PHP код:
DisablePlayerCheckpoint(playerid); 
This forum requires that you wait 120 seconds between posts. Please try again in 73 seconds.


EDIT: Late.


Re: If you exit a vehicle, it cancels the job. (need help) - Marricio - 12.09.2011

The thing you doing wrong is almost all the code you did show.
You're creating a global var, so if you change something, you aint changing it to the x player.
You know what i mean right? You need to change the var.

Original
pawn Код:
new simplejobrunning = 0;
Fixed
pawn Код:
new simplejobrunning[MAX_PLAYERS] = 0;
You see the difference right?

The way you used to check the var value seemed strange to me, maybe not my way, i changed it, feel free to do what you want from the code.

Original
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    if((simplejobrunning) == 1)
    {
        simplejobrunning = 0;
        SendClientMessage(playerid, COLOR_RED, "You're job was canceled due to exiting the Vehicle");

    }else if((simplejobrunning) == 0){

       
 }
}
Possibily Fixed
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    if(simplejobrunning[playerid] == 1) // this will check the value to 'playerid'
    {
        simplejobrunning[playerid] = 0; // this will change the value to 'playerid'
        SendClientMessage(playerid, COLOR_RED, "You're job was canceled due to exiting the Vehicle");
        DisablePlayerCheckpoint(playerid); // this will dissapear/disable the current player cp
        return 1;
    }
    else if(simplejobrunning[playerid] == 0)
    {
        return 1;
    }
    return 1;
}
You see the difference right?

This is not tested, but compiled, dont blame me if it doesn't works.

Good luck


Re: If you exit a vehicle, it cancels the job. (need help) - rangerxxll - 12.09.2011

Quote:
Originally Posted by Marricio
Посмотреть сообщение
The thing you doing wrong is almost all the code you did show.
You're creating a global var, so if you change something, you aint changing it to the x player.
You know what i mean right? You need to change the var.

Original
pawn Код:
new simplejobrunning = 0;
Fixed
pawn Код:
new simplejobrunning[MAX_PLAYERS] = 0;
You see the difference right?

The way you used to check the var value seemed strange to me, maybe not my way, i changed it, feel free to do what you want from the code.

Original
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    if((simplejobrunning) == 1)
    {
        simplejobrunning = 0;
        SendClientMessage(playerid, COLOR_RED, "You're job was canceled due to exiting the Vehicle");

    }else if((simplejobrunning) == 0){

       
 }
}
Possibily Fixed
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    if(simplejobrunning[playerid] == 1) // this will check the value to 'playerid'
    {
        simplejobrunning[playerid] = 0; // this will change the value to 'playerid'
        SendClientMessage(playerid, COLOR_RED, "You're job was canceled due to exiting the Vehicle");
        DisablePlayerCheckpoint(playerid); // this will dissapear/disable the current player cp
        return 1;
    }
    else if(simplejobrunning[playerid] == 0)
    {
        return 1;
    }
    return 1;
}
You see the difference right?

This is not tested, but compiled, dont blame me if it doesn't works.

Good luck
You explained it very well, I'm about to try it out. Thank you very much.


Re: If you exit a vehicle, it cancels the job. (need help) - rangerxxll - 12.09.2011

Quote:
Originally Posted by Marricio
Посмотреть сообщение
The thing you doing wrong is almost all the code you did show.
You're creating a global var, so if you change something, you aint changing it to the x player.
You know what i mean right? You need to change the var.

Original
pawn Код:
new simplejobrunning = 0;
Fixed
pawn Код:
new simplejobrunning[MAX_PLAYERS] = 0;
You see the difference right?

The way you used to check the var value seemed strange to me, maybe not my way, i changed it, feel free to do what you want from the code.

Original
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    if((simplejobrunning) == 1)
    {
        simplejobrunning = 0;
        SendClientMessage(playerid, COLOR_RED, "You're job was canceled due to exiting the Vehicle");

    }else if((simplejobrunning) == 0){

       
 }
}
Possibily Fixed
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    if(simplejobrunning[playerid] == 1) // this will check the value to 'playerid'
    {
        simplejobrunning[playerid] = 0; // this will change the value to 'playerid'
        SendClientMessage(playerid, COLOR_RED, "You're job was canceled due to exiting the Vehicle");
        DisablePlayerCheckpoint(playerid); // this will dissapear/disable the current player cp
        return 1;
    }
    else if(simplejobrunning[playerid] == 0)
    {
        return 1;
    }
    return 1;
}
You see the difference right?

This is not tested, but compiled, dont blame me if it doesn't works.

Good luck
It doesn't work in-game. Is something wrong with it? I've checked, but I'm not really sure.


Re: If you exit a vehicle, it cancels the job. (need help) - Dr - 12.09.2011

Use this:

pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    if(simplejobrunning[playerid] == 1)
    {
        simplejobrunning[playerid] = 0;
        SendClientMessage(playerid, COLOR_RED, "You're job was canceled due to exiting the Vehicle");
        DisablePlayerCheckpoint(playerid);
    }
    return 1;
}
Also make sure you replaced any:
pawn Код:
simplejobrunning
With:
pawn Код:
simplejobrunning[playerid]



Re: If you exit a vehicle, it cancels the job. (need help) - Marricio - 12.09.2011

Ummm, maybe, you've set the value (1) when X player is starting the job?


Re: If you exit a vehicle, it cancels the job. (need help) - rangerxxll - 12.09.2011

Quote:
Originally Posted by Dr
Посмотреть сообщение
Use this:

pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    if(simplejobrunning[playerid] == 1)
    {
        simplejobrunning[playerid] = 0;
        SendClientMessage(playerid, COLOR_RED, "You're job was canceled due to exiting the Vehicle");
        DisablePlayerCheckpoint(playerid);
    }
    return 1;
}
Also make sure you replaced any:
pawn Код:
simplejobrunning
With:
pawn Код:
simplejobrunning[playerid]
Quote:

C:\Documents and Settings\Lucas\Desktop\Serverstuff\MyTestServerV1. 0\filterscripts\SimpleJob.pwn(12) : error 010: invalid function or declaration
C:\Documents and Settings\Lucas\Desktop\Serverstuff\MyTestServerV1. 0\filterscripts\SimpleJob.pwn(116) : error 017: undefined symbol "simplejobrunning"
C:\Documents and Settings\Lucas\Desktop\Serverstuff\MyTestServerV1. 0\filterscripts\SimpleJob.pwn(116) : warning 215: expression has no effect
C:\Documents and Settings\Lucas\Desktop\Serverstuff\MyTestServerV1. 0\filterscripts\SimpleJob.pwn(116) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\Lucas\Desktop\Serverstuff\MyTestServerV1. 0\filterscripts\SimpleJob.pwn(116) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Lucas\Desktop\Serverstuff\MyTestServerV1. 0\filterscripts\SimpleJob.pwn(116) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


5 Errors.

I get those errors.


Re: If you exit a vehicle, it cancels the job. (need help) - Dr - 12.09.2011

pawn Code:
simplejobrunning[playerid];
Make sure you put the:
pawn Code:
;



Re: If you exit a vehicle, it cancels the job. (need help) - rangerxxll - 12.09.2011

Quote:
Originally Posted by Dr
View Post
pawn Code:
simplejobrunning[playerid];
Make sure you put the:
pawn Code:
;
This is my current code, it compiles fine but does not work in-game.

pawn Code:
new simplejobrunning[MAX_PLAYERS];
pawn Code:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    if(simplejobrunning[playerid] == 1)
    {
        simplejobrunning[playerid] = 0;
        SendClientMessage(playerid, COLOR_RED, "You're job was canceled due to exiting the Vehicle");
        DisablePlayerCheckpoint(playerid);
    }
    return 1;
}
Do I change
pawn Code:
new simplejobrunning[MAX_PLAYERS];
to
pawn Code:
new simplejobrunning[playerid];
?


Re: If you exit a vehicle, it cancels the job. (need help) - Marricio - 12.09.2011

This can be more efficient
pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_ONFOOT && oldstate == PLAYER_STATE_DRIVER)
    {
        if(simplejobrunning[playerid] == 1) // this will check the value to 'playerid'
        {
            simplejobrunning[playerid] = 0; // this will change the value to 'playerid'
            SendClientMessage(playerid, COLOR_RED, "You're job was canceled due to exiting the Vehicle");
            DisablePlayerCheckpoint(playerid); // this will dissapear/disable the current player cp
            return 1;
        }
    }
    return 1;
}
Compiled


Re: If you exit a vehicle, it cancels the job. (need help) - rangerxxll - 12.09.2011

Quote:
Originally Posted by Marricio
View Post
This can be more efficient
pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_ONFOOT && oldstate == PLAYER_STATE_DRIVER)
    {
        if(simplejobrunning[playerid] == 1) // this will check the value to 'playerid'
        {
            simplejobrunning[playerid] = 0; // this will change the value to 'playerid'
            SendClientMessage(playerid, COLOR_RED, "You're job was canceled due to exiting the Vehicle");
            DisablePlayerCheckpoint(playerid); // this will dissapear/disable the current player cp
            return 1;
        }
    }
    return 1;
}
Compiled
I compiled it as well, but it doesn't work in-game.


Re: If you exit a vehicle, it cancels the job. (need help) - Marricio - 12.09.2011

Well like i said before.
Quote:
Originally Posted by Marricio
Посмотреть сообщение
Ummm, maybe, you've set the value (1) when X player is starting the job?