Help with making /work system.
#1

Well, I'm working on a /work system for my flying server, since the current way to get score + money is to fly. That seems boring, so I'm starting work on this basic system, which will prboably be expanded in the future.

Now, there is no errors, but there is one things I canot get passed, setting the next check point for the final destenation.

Here is my script.

pawn Код:
#include <a_samp>
#include <zcmd>

#define COLOR_WHITE 0xFFFFFFFF

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print("Pilot Job system by TechKid100");
    print("--------------------------------------\n");
    return 1;
}

enum Work
{
    IsWorking,
}

new WorkInfo[MAX_PLAYERS][Work];

public OnPlayerConnect(playerid)
{
    WorkInfo[playerid][IsWorking] = 0;
    return 1;
}

public OnPlayerDisconnect(playerid)
{
    WorkInfo[playerid][IsWorking] = 0;
    return 1;
}

COMMAND:work(playerid, params[])
{
    if(!IsPlayerInPlane(playerid) && WorkInfo[playerid][IsWorking] == 0)
    {
        SendClientMessage(playerid, COLOR_WHITE, "{FF0000}Error: {FFFFFF}You need to be in a plane to work!");
        return 1;
    }
   
    else if (WorkInfo[playerid][IsWorking] == 1 && IsPlayerInPlane(playerid))
    {
        SendClientMessage(playerid, COLOR_WHITE, "{FF0000}Error: {FFFFFF}You are allready working!");
        return 1;
    }

    //Flights
    else if (WorkInfo[playerid][IsWorking] == 0 && IsPlayerInPlane(playerid))
    {
        //Lv to Sf (Flight 1)
        if(IsPlayerInRangeOfPoint(playerid, 1000, 1580.8534, 1534.2217, 10.8316))
        {
            WorkInfo[playerid][IsWorking] = 1;
            SendClientMessage(playerid, COLOR_WHITE, "Complete flight from {FFFF00}LVAP {FFFFFF}to {FFFF00}SFAP.");
            SetPlayerRaceCheckpoint(playerid, 2, 1580.8534, 1534.2217, 10.8316, -1371.3795,-206.3711,14.1484, 5);
            return 1;
        }
       
       
        //Sf to Ls (Flight 2)
        else if(IsPlayerInRangeOfPoint(playerid, 1000, 1580.8534, 1534.2217, 10.8316))
        {
            WorkInfo[playerid][IsWorking] = 1;
            SendClientMessage(playerid, COLOR_WHITE, "Complete flight from {FFFF00}SFAP {FFFFFF}to {FFFF00}LSAP.");
            SetPlayerRaceCheckpoint(playerid, 2, -1371.3795,-206.3711,14.1484, 1721.4504,-2415.5193,13.5547, 5);
            return 1;
        }
       
        //Ls to Lv (Flight 3)
        else if(IsPlayerInRangeOfPoint(playerid, 1000, 1580.8534, 1534.2217, 10.8316))
        {
            WorkInfo[playerid][IsWorking] = 1;
            SendClientMessage(playerid, COLOR_WHITE, "Complete flight from {FFFF00}LSAP {FFFFFF}to {FFFF00}LVAP.");
            SetPlayerRaceCheckpoint(playerid, 2, 1721.4504, -2415.5193, 13.5547, 1580.8534, 1534.2217, 10.8316, 5);
            return 1;
        }
       
    }
   
    return 0;
}

COMMAND:stopwork(playerid, params[])
{
    if(WorkInfo[playerid][IsWorking] == 0)
    {
        SendClientMessage(playerid, COLOR_WHITE, "{FF0000}Error: {FFFFFF}You are not working!");
        return 1;
    }
   
    else if (WorkInfo[playerid][IsWorking] == 1)
    {
        WorkInfo[playerid][IsWorking] = 0;
        SendClientMessage(playerid, COLOR_WHITE, "Work has been stoped!");
        DisablePlayerRaceCheckpoint(playerid);
        return 1;
    }
    return 0;
}


public OnPlayerEnterCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid)
{
    WorkInfo[playerid][IsWorking] = 0;
    return 1;
}

stock IsPlayerInPlane(playerid)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        switch(GetVehicleModel(GetPlayerVehicleID(playerid)))
        {
            case 593,592,577,563,553,548,520,519,513,512,511,
            497,488,487,476,469,460,447,425,417,493,484,453: return 1;
            default: return 0;
        }
    }
    return 0;
}
Now, what I really want to do is so when a player enters the first checpoint, its knows it the first checkpoint, so it dosent give the player the reward. So it needs to set the last checkpoint. And when a player enters that last checkpoint, it gives the player 10k and 1 score, and set's the work to off.

I just dont know how to get around it.

Lets take this for example.

pawn Код:
//Lv to Sf
        if(IsPlayerInRangeOfPoint(playerid, 1000, 1580.8534, 1534.2217, 10.8316))
        {
            WorkInfo[playerid][IsWorking] = 1;
            SendClientMessage(playerid, COLOR_WHITE, "Complete flight from {FFFF00}LVAP {FFFFFF}to {FFFF00}SFAP.");
            SetPlayerRaceCheckpoint(playerid, 2, 1580.8534, 1534.2217, 10.8316, -1371.3795,-206.3711,14.1484, 5);
            return 1;
        }
SetPlayerRaceCheckpoint(playerid, 2, 1580.8534, 1534.2217, 10.8316, -1371.3795,-206.3711,14.1484, 5);

As you can see it is setting the next checkpoint but I dont know how to get around this.
Reply
#2

You want the server to know when the player reaches his last checkpoint to give him a reward when he completes two checkpoints, from LS to SF, then from SF to LV?
Reply
#3

I have renamed the flight in the scripts as Flight 1, Flight 2, for better explanation.

So, say if im in LVA, and do /work, it will automaticly set the flight to Flight 1 becuse it is the closet airport, so I taxi to the checkpoint, once I enter it, I makes another checkpoint at San Fiero, becuase thats the next destentaion. So once I land at San Fiero and go into the checkpoint it gives me the reward. And I can do /work again and it will choose a flight based on the closest airport.

Hope that explained it.
Reply
#4

pawn Код:
public OnPlayerEnterRaceCheckpoint(playerid)
{
    if(IsPlayerInRangeOfPoint(playerid, 10, X, Y, Z)) // First checkpoint cordinates
    {
        SetPlayerRaceCheckpoint(...........);//Next Checkpoint
        return 1;
    }
    if(IsPlayerInRangeOfPoint(playerid, 10, X, Y, Z)) // Second checkpoint cordinates
    {
        SetPlayerRaceCheckpoint(...........);//Next Checkpoint or you can give money or whatever
        return 1;
    }
    return 1;
}
I never worked with checkpoints but i think it will work
Reply
#5

Hmmm, I dont think that would work.
Reply
#6

Quote:
Originally Posted by techkid100
Посмотреть сообщение
Hmmm, I dont think that would work.
Why not?

When player enter his checkpoint that public is called
So it will check player position on that way we doing something like checking for checkpoint id ID
Reply
#7

Aww fuck, im dumb for forgeting that, ill try it now,
Reply
#8

pawn Код:
if(strcmp(cmdtext, "/work", true) == 0)
    {
        if(IsPlayerInRangeOfPoint(playerid, 1000, 1580.8534, 1534.2217, 10.8316))
        {
            //WorkInfo[playerid][IsWorking] = 1;
            SendClientMessage(playerid, COLOR_WHITE, "Complete flight from {FFFF00}LVAP {FFFFFF}to {FFFF00}SFAP.");
            SetPlayerCheckpoint(playerid, 1580.8534, 1534.2217, 10.8316, 5);
            return 1;
        }
        //Sf to Ls (Flight 2)
        else if(IsPlayerInRangeOfPoint(playerid, 1000, 1580.8534, 1534.2217, 10.8316))
        {
            //WorkInfo[playerid][IsWorking] = 2;
            SendClientMessage(playerid, COLOR_WHITE, "Complete flight from {FFFF00}SFAP {FFFFFF}to {FFFF00}LSAP.");
            SetPlayerCheckpoint(playerid, -1371.3795,-206.3711,14.1484, 5);
            return 1;
        }

        //Ls to Lv (Flight 3)
        else if(IsPlayerInRangeOfPoint(playerid, 1000, 1580.8534, 1534.2217, 10.8316))
        {
            //WorkInfo[playerid][IsWorking] = 3;
            SendClientMessage(playerid, COLOR_WHITE, "Complete flight from {FFFF00}LSAP {FFFFFF}to {FFFF00}LVAP.");
            SetPlayerCheckpoint(playerid, 1721.4504, -2415.5193, 13.5547, 5);
            return 1;
        }

    }
pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
    if(WorkInfo[playerid][IsWorking] = 1)
    {
        SetPlayerCheckpoint(playerid, 0.0, 0.0, 0.0, 5);//change coordinates to flight one landing
    }
    else if(WorkInfo[playerid][IsWorking] = 2)
    {
        SetPlayerCheckpoint(playerid, 0.0, 0.0, 0.0, 5);//change to flight 2 landing
    }
    else
    {
        SetPlayercheckpoint(playerid, 0.0, 0.0, 0.0, 5);//change to flight 3 landing
    }
    return 1;
}
Change your current code in /work with this one:
pawn Код:
else if (WorkInfo[playerid][IsWorking] > 0 && IsPlayerInPlane(playerid))
{
    SendClientMessage(playerid, COLOR_WHITE, "{FF0000}Error: {FFFFFF}You are allready working!");
    return 1;
}
I've changed the variable WorkInfo[playerid][IsWorking]'s use:
pawn Код:
WorkInfo[playerid][IsWorking] == 1 //means Flight 1
WorkInfo[playerid][IsWorking] == 2 //means Flight 2
WorkInfo[playerid][IsWorking] //means Flight 3
If you wanna check if the player is working you can do:
pawn Код:
if(WorkInfo[playerid][IsWorking] > 0)
Reply
#9

New scipt:

pawn Код:
#include <a_samp>
#include <zcmd>

#define COLOR_WHITE 0xFFFFFFFF

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print("Pilot Job system by TechKid100");
    print("--------------------------------------\n");
    return 1;
}

enum Work
{
    IsWorking,
}

new WorkInfo[MAX_PLAYERS][Work];

public OnPlayerConnect(playerid)
{
    WorkInfo[playerid][IsWorking] = 0;
    return 1;
}

public OnPlayerDisconnect(playerid)
{
    WorkInfo[playerid][IsWorking] = 0;
    return 1;
}

COMMAND:work(playerid, params[])
{
        if(!IsPlayerInPlane(playerid) && WorkInfo[playerid][IsWorking] == 0)
        {
            SendClientMessage(playerid, COLOR_WHITE, "{FF0000}Error: {FFFFFF}You need to be in a plane to work!");
            return 1;
        }
       
        if(WorkInfo[playerid][IsWorking] > 0)
        {
            SendClientMessage(playerid, COLOR_WHITE, "{FF0000}Error: {FFFFFF}You are allready working!");
        }
       
        else if(IsPlayerInRangeOfPoint(playerid, 1000, 1580.8534, 1534.2217, 10.8316))
        {
            WorkInfo[playerid][IsWorking] = 1;
            SendClientMessage(playerid, COLOR_WHITE, "Complete flight from {FFFF00}LVAP {FFFFFF}to {FFFF00}SFAP.");
            SetPlayerCheckpoint(playerid, 1580.8534, 1534.2217, 10.8316, 5);
            return 1;
        }
        //Sf to Ls (Flight 2)
        else if(IsPlayerInRangeOfPoint(playerid, 1000, -1371.3795,-206.3711,14.1484))
        {
            WorkInfo[playerid][IsWorking] = 2;
            SendClientMessage(playerid, COLOR_WHITE, "Complete flight from {FFFF00}SFAP {FFFFFF}to {FFFF00}LSAP.");
            SetPlayerCheckpoint(playerid, -1371.3795,-206.3711,14.1484, 5);
            return 1;
        }

        //Ls to Lv (Flight 3)
        else if(IsPlayerInRangeOfPoint(playerid, 1000, 1721.4504,-2415.5193,13.5547))
        {
            WorkInfo[playerid][IsWorking] = 3;
            SendClientMessage(playerid, COLOR_WHITE, "Complete flight from {FFFF00}LSAP {FFFFFF}to {FFFF00}LVAP.");
            SetPlayerCheckpoint(playerid, 1721.4504, -2415.5193, 13.5547, 5);
            return 1;
        }
        return 1;
    }
   
COMMAND:stopwork(playerid, params[])
{
    if(WorkInfo[playerid][IsWorking] == 0)
    {
        SendClientMessage(playerid, COLOR_WHITE, "{FF0000}Error: {FFFFFF}You are not working!");
        return 1;
    }
    else if(WorkInfo[playerid][IsWorking] > 0)
    {
        SendClientMessage(playerid, COLOR_WHITE, "Work has been cancled!");
        WorkInfo[playerid][IsWorking] = 0;
        return 1;
    }
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    if(WorkInfo[playerid][IsWorking] == 1)
    {
        SetPlayerCheckpoint(playerid, -1371.3795,-206.3711,14.1484, 5);//change coordinates to flight one landing
        GameTextForPlayer(playerid,"~g~Passegers Boarded!",3000,3);
    }
    else if(WorkInfo[playerid][IsWorking] == 2)
    {
        SetPlayerCheckpoint(playerid, 1721.4504,-2415.5193,13.5547, 5);//change to flight 2 landing
        GameTextForPlayer(playerid,"~g~Passegers Boarded!",3000,3);
    }
    else
    {
        SetPlayerCheckpoint(playerid, 1580.8534,1534.2217,10.8316, 5);//change to flight 3 landing
        GameTextForPlayer(playerid,"~g~Passegers Boarded!",3000,3);
    }
    return 1;
}

public OnPlayerDeath(playerid)
{
    WorkInfo[playerid][IsWorking] = 0;
    return 1;
}

stock IsPlayerInPlane(playerid)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        switch(GetVehicleModel(GetPlayerVehicleID(playerid)))
        {
            case 593,592,577,563,553,548,520,519,513,512,511,
            497,488,487,476,469,460,447,425,417,493,484,453: return 1;
            default: return 0;
        }
    }
    return 0;
}
All I need help with now is making it so when he enters the last checkpoint, it sets the work to off, and then gives him 12k and 2 score.
Reply
#10

I feel something's strange that will not work in the OnPlayerEnterCheckpoint callback...

I could make somethin' like dis :

pawn Код:
/*
    W O R K
*/


#include < a_samp >
#include < zcmd >

#define COLOR_WHITE ( 0xFFFFFFAA )

#pragma tabsize 0 // lazy xD

enum    e_work_info ( <<= 1 )
{
    work_info_none,
    work_info_boarding,
    work_info_travelling
}

new
    gCPInfo[ MAX_PLAYERS ] = { -1, ... },
    e_work_info: gWorkInfo[ MAX_PLAYERS ] = { work_info_none, ... }
;

CMD:work( playerid, params[ ] )
{
    if ( !IsPlayerInPlane( playerid ) )
        return SendClientMessage( playerid, -1, "{AA0000}You are not in any plane." );
       
    if ( gWorkInfo[ playerid ] != work_info_none )
        return SendClientMessage( playerid, -1, "{AA0000}You are already working!" );
       
    gWorkInfo[ playerid ] = work_info_travelling;
   
    if(IsPlayerInRangeOfPoint(playerid, 1000, 1580.8534, 1534.2217, 10.8316))
    {
        gCPInfo[ playerid ] = 0;
        SendClientMessage(playerid, COLOR_WHITE, "Complete flight from {FFFF00}LVAP {FFFFFF}to {FFFF00}SFAP.");
        SetPlayerCheckpoint(playerid, 1580.8534, 1534.2217, 10.8316, 5);
        return 1;
    }
       
    else if(IsPlayerInRangeOfPoint(playerid, 1000, -1371.3795,-206.3711,14.1484))
    {
        gCPInfo[ playerid ] = 1;
        SendClientMessage(playerid, COLOR_WHITE, "Complete flight from {FFFF00}SFAP {FFFFFF}to {FFFF00}LSAP.");
        SetPlayerCheckpoint(playerid, -1371.3795,-206.3711,14.1484, 5);
        return 1;
    }
   
    else if(IsPlayerInRangeOfPoint(playerid, 1000, 1721.4504,-2415.5193,13.5547))
    {
        gCPInfo[ playerid ] = 2;
        SendClientMessage(playerid, COLOR_WHITE, "Complete flight from {FFFF00}LSAP {FFFFFF}to {FFFF00}LVAP.");
        SetPlayerCheckpoint(playerid, 1721.4504, -2415.5193, 13.5547, 5);
        return 1;
    }
    return 1;
}

CMD:stopwork( playerid, params[ ] )
{
    if ( gWorkInfo[ playerid ] == work_info_none )
        return SendClientMessage( playerid, -1, "{AA0000}You are not working!" );
       
    gWorkInfo[ playerid ] = work_info_none;
   
    SendClientMessage( playerid, -1, "{AA0000}You have stopped the mission." );
   
    return 1;
}

public OnPlayerEnterCheckpoint( playerid )
{
        if ( gWorkInfo[ playerid ] == work_info_travelling )
        {
            switch ( gCPInfo[ playerid ] )
            {
                case 0 :
                {
                    SetPlayerCheckpoint(playerid, -1371.3795,-206.3711,14.1484, 5);
                    GameTextForPlayer(playerid,"~g~Passegers Boarded!",3000,3);
                   
                    gWorkInfo[ playerid ] = work_info_boarding;
                }

                case 1 :
                {
                    SetPlayerCheckpoint(playerid, 1721.4504,-2415.5193,13.5547, 5);
                    GameTextForPlayer(playerid,"~g~Passegers Boarded!",3000,3);
                   
                    gWorkInfo[ playerid ] = work_info_boarding;
                }
               
                case 2 :
                {
                    SetPlayerCheckpoint(playerid, 1580.8534,1534.2217,10.8316, 5);
                    GameTextForPlayer(playerid,"~g~Passegers Boarded!",3000,3);
                }
            }
        }
       
        if ( gWorkInfo[ playerid ] == work_info_boarding )
        {
            DisablePlayerCheckpoint( playerid );
           
            gWorkInfo[ playerid ] = work_info_none;
           
            GivePlayerMoney( playerid, 12000 );
           
            SetPlayerScore( playerid, GetPlayerScore( playerid ) + 2 );
           
            GameTextForPlayer( playerid, "~g~Mission finished", 3000, 3 );
        }
   
    return 1;
}

stock IsPlayerInPlane(playerid)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        switch(GetVehicleModel(GetPlayerVehicleID(playerid)))
        {
            case 593,592,577,563,553,548,520,519,513,512,511,
            497,488,487,476,469,460,447,425,417,493,484,453: return 1;
            default: return 0;
        }
    }
    return 0;
}
That code should works
Reply
#11

Thanks! I was just half way throught rescripting it with.

pawn Код:
enum Work
{
    IsWorking,
    Flight1,
    Flight2,
    Flight3,
    Flight1Final,
    Flight2Final,
    Flight3Final,
}
So I quickly whipped on yours and this happened:



It gave me the reward on the first checkpoint.
Reply
#12

Hmm, I added some checks, still unsure though.

pawn Код:
/*
    W O R K
*/


#include < a_samp >
#include < zcmd >
#include < sii >

#define COLOR_WHITE ( 0xFFFFFFAA )

#pragma tabsize 0 // lazy xD

enum    e_work_info ( <<= 1 )
{
    work_info_none,
    work_info_boarding,
    work_info_travelling
}

new
    gCPInfo[ MAX_PLAYERS ] = { -1, ... },
    e_work_info: gWorkInfo[ MAX_PLAYERS ] = { work_info_none, ... }
;

CMD:work( playerid, params[ ] )
{
    if ( !IsPlayerInPlane( playerid ) )
        return SendClientMessage( playerid, -1, "{AA0000}You are not in any plane." );
       
    if ( gWorkInfo[ playerid ] != work_info_none )
        return SendClientMessage( playerid, -1, "{AA0000}You are already working!" );
       
    gWorkInfo[ playerid ] = work_info_travelling;
   
    if(IsPlayerInRangeOfPoint(playerid, 1000, 1580.8534, 1534.2217, 10.8316))
    {
        gCPInfo[ playerid ] = 0;
        SendClientMessage(playerid, COLOR_WHITE, "Complete flight from {FFFF00}LVAP {FFFFFF}to {FFFF00}SFAP.");
        SetPlayerCheckpoint(playerid, 1580.8534, 1534.2217, 10.8316, 5);
        return 1;
    }
       
    else if(IsPlayerInRangeOfPoint(playerid, 1000, -1371.3795,-206.3711,14.1484))
    {
        gCPInfo[ playerid ] = 1;
        SendClientMessage(playerid, COLOR_WHITE, "Complete flight from {FFFF00}SFAP {FFFFFF}to {FFFF00}LSAP.");
        SetPlayerCheckpoint(playerid, -1371.3795,-206.3711,14.1484, 5);
        return 1;
    }
   
    else if(IsPlayerInRangeOfPoint(playerid, 1000, 1721.4504,-2415.5193,13.5547))
    {
        gCPInfo[ playerid ] = 2;
        SendClientMessage(playerid, COLOR_WHITE, "Complete flight from {FFFF00}LSAP {FFFFFF}to {FFFF00}LVAP.");
        SetPlayerCheckpoint(playerid, 1721.4504, -2415.5193, 13.5547, 5);
        return 1;
    }
    return 1;
}

CMD:stopwork( playerid, params[ ] )
{
    if ( gWorkInfo[ playerid ] == work_info_none )
        return SendClientMessage( playerid, -1, "{AA0000}You are not working!" );
       
    gWorkInfo[ playerid ] = work_info_none;
   
    SendClientMessage( playerid, -1, "{AA0000}You have stopped the mission." );
   
    return 1;
}

public OnPlayerEnterCheckpoint( playerid )
{
        if ( gWorkInfo[ playerid ] == work_info_travelling )
        {
            switch ( gCPInfo[ playerid ] )
            {
                case 0 :
                {
                    if ( gWorkInfo[ playerid ] != work_info_travelling )
                        return -1;
                       
                    SetPlayerCheckpoint(playerid, -1371.3795,-206.3711,14.1484, 5);
                    GameTextForPlayer(playerid,"~g~Passegers Boarded!",3000,3);
                   
                    gWorkInfo[ playerid ] = work_info_boarding;
                }

                case 1 :
                {
                    if ( gWorkInfo[ playerid ] != work_info_travelling )
                        return -1;
                       
                    SetPlayerCheckpoint(playerid, 1721.4504,-2415.5193,13.5547, 5);
                    GameTextForPlayer(playerid,"~g~Passegers Boarded!",3000,3);
                   
                    gWorkInfo[ playerid ] = work_info_boarding;
                }
               
                case 2 :
                {
                    if ( gWorkInfo[ playerid ] != work_info_travelling )
                        return -1;
                       
                    SetPlayerCheckpoint(playerid, 1580.8534,1534.2217,10.8316, 5);
                    GameTextForPlayer(playerid,"~g~Passegers Boarded!",3000,3);
                }
            }
        }
       
        if ( gWorkInfo[ playerid ] == work_info_boarding )
        {
            if ( gWorkInfo[ playerid ] != work_info_boarding )
                        return -1;
                       
            DisablePlayerCheckpoint( playerid );
           
            gWorkInfo[ playerid ] = work_info_none;
           
            GivePlayerMoney( playerid, 12000 );
           
            SetPlayerScore( playerid, GetPlayerScore( playerid ) + 2 );
           
            GameTextForPlayer( playerid, "~g~Mission finished", 3000, 3 );
        }
   
    return 1;
}

stock IsPlayerInPlane(playerid)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        switch(GetVehicleModel(GetPlayerVehicleID(playerid)))
        {
            case 593,592,577,563,553,548,520,519,513,512,511,
            497,488,487,476,469,460,447,425,417,493,484,453: return 1;
            default: return 0;
        }
    }
    return 0;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)