Question and help about one function
#1

Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if( oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER )
    {
    //If they got into a car from being on foot.
        if( GetVehicleModel(GetPlayerVehicleID( playerid )) == 428)  //naudoti || masina ||
        {
            if( GetPlayerSkin(playerid) != 27) //naudoti || skinas ||
            {
                //If their skin is not 27
                //Remove them and send message.
                RemovePlayerFromVehicle( playerid );
                SendClientMessage( playerid,0xFF000000, "Noredami vairuoti si transporta turite buti elektriku" );//-1
                return 1;
            }
            else
            {
                SendClientMessage(playerid, 0xFF000000, "Atsisedote i transporta. Jeigu dirbate, tada dirbkite savo darba");
                return 1;
            }
        }
    }
    return 1;
}
You see this code? This is for workers with skin 27 and car with id 426.
How can i do more vehicles for skin 27? Or how can i do tank for soldier skin? Or how can i do more vehicles for soldier skin or other skins?
Reply
#2

help me!!!
Reply
#3

help me finally!!!
Reply
#4

pawn Code:
new workers[MAX_PLAYERS][playerid] = // The list of skin ids that are allowed.
{
    27,
    38,
    29,
    213,
    219,
    6
    };
   
    if( oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER )
    {
    //If they got into a car from being on foot.
        if( GetVehicleModel(GetPlayerVehicleID( playerid )) == 428)  //naudoti || masina ||
        {
            if( GetPlayerSkin(playerid) != workers) //naudoti || skinas ||
           
            {
                //If their skin is not 27
                //Remove them and send message.
                RemovePlayerFromVehicle( playerid );
                SendClientMessage( playerid,0xFF000000, "Noredami vairuoti si transporta turite buti elektriku" );//-1
                return 1;
            }
            else
            {
                SendClientMessage(playerid, 0xFF000000, "Atsisedote i transporta. Jeigu dirbate, tada dirbkite savo darba");
                return 1;
            }
        }
    }
    return 1;
}
Rep Please =3
Reply
#5

Quote:
Originally Posted by Vrondakis
View Post
pawn Code:
new workers[MAX_PLAYERS][playerid] = // The list of skin ids that are allowed.
{
    27,
    38,
    29,
    213,
    219,
    6
    };
   
    if( oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER )
    {
    //If they got into a car from being on foot.
        if( GetVehicleModel(GetPlayerVehicleID( playerid )) == 428)  //naudoti || masina ||
        {
            if( GetPlayerSkin(playerid) != workers) //naudoti || skinas ||
           
            {
                //If their skin is not 27
                //Remove them and send message.
                RemovePlayerFromVehicle( playerid );
                SendClientMessage( playerid,0xFF000000, "Noredami vairuoti si transporta turite buti elektriku" );//-1
                return 1;
            }
            else
            {
                SendClientMessage(playerid, 0xFF000000, "Atsisedote i transporta. Jeigu dirbate, tada dirbkite savo darba");
                return 1;
            }
        }
    }
    return 1;
}
Rep Please =3
Ok i gave you rep. But how to make soldier skin with tank, hydra, truck etc... ?
Reply
#6

You do it in the same way. If you want all the "workers" to be allowed to get in the hydra + tank + truck, you do the exact same thing.

pawn Code:
new workers[MAX_PLAYERS][playerid] = // The list of skin ids that are allowed.
{
    27,
    38,
    29,
    213,
    219,
    6
    };

new vehicles[MAX_PLAYERS][playerid] = // The list of vehicles that the workers are allowed to get into.
{
    520,
    528,
    532,
    };


    if( oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER )
    {
    //If they got into a car from being on foot.
        if( GetVehicleModel(GetPlayerVehicleID( playerid )) == vehicles)  //naudoti || masina ||
        {
            if( GetPlayerSkin(playerid) != workers) //naudoti || skinas ||

            {
                //If their skin is not 27
                //Remove them and send message.
                RemovePlayerFromVehicle( playerid );
                SendClientMessage( playerid,0xFF000000, "Noredami vairuoti si transporta turite buti elektriku" );//-1
                return 1;
            }
            else
            {
                SendClientMessage(playerid, 0xFF000000, "Atsisedote i transporta. Jeigu dirbate, tada dirbkite savo darba");
                return 1;
            }
        }
    }
    return 1;
}
Should work, not tested
Reply
#7

You could also just use the team variable for workers....
Reply
#8

Quote:
Originally Posted by Vrondakis
View Post
You do it in the same way. If you want all the "workers" to be allowed to get in the hydra + tank + truck, you do the exact same thing.

pawn Code:
new workers[MAX_PLAYERS][playerid] = // The list of skin ids that are allowed.
{
    27,
    38,
    29,
    213,
    219,
    6
    };

new vehicles[MAX_PLAYERS][playerid] = // The list of vehicles that the workers are allowed to get into.
{
    520,
    528,
    532,
    };


    if( oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER )
    {
    //If they got into a car from being on foot.
        if( GetVehicleModel(GetPlayerVehicleID( playerid )) == vehicles)  //naudoti || masina ||
        {
            if( GetPlayerSkin(playerid) != workers) //naudoti || skinas ||

            {
                //If their skin is not 27
                //Remove them and send message.
                RemovePlayerFromVehicle( playerid );
                SendClientMessage( playerid,0xFF000000, "Noredami vairuoti si transporta turite buti elektriku" );//-1
                return 1;
            }
            else
            {
                SendClientMessage(playerid, 0xFF000000, "Atsisedote i transporta. Jeigu dirbate, tada dirbkite savo darba");
                return 1;
            }
        }
    }
    return 1;
}
Should work, not tested
Big error. Can you give a full function?
Look just do a hydra,rhino,rustler,dodo for a soldier skin, and make a car with ID 428 only available for skin 27, same with soldier. And teach me better how to add vehicles and skins for other works like trucker, medic and etc...
Reply
#9

pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
new vehicles[MAX_PLAYERS][playerid] =
{
520, // hydra
593, // dodo
376, // rustler
432}; // rhino

    if( oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER )
    {
    //If they got into a car from being on foot.
        if( GetVehicleModel(GetPlayerVehicleID( playerid )) == vehicles)  //naudoti || masina ||
        {
            if( GetPlayerSkin(playerid) != 27) //naudoti || skinas ||

            {
                //If their skin is not 27
                //Remove them and send message.
                RemovePlayerFromVehicle( playerid );
                SendClientMessage( playerid,0xFF000000, "Noredami vairuoti si transporta turite buti elektriku" );//-1
                return 1;
            }
            else
            {
                SendClientMessage(playerid, 0xFF000000, "Atsisedote i transporta. Jeigu dirbate, tada dirbkite savo darba");
                return 1;
            }
        }
    }
    return 1;
}
Should work. I fixed it
Reply
#10

Quote:
Originally Posted by Vrondakis
View Post
pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
new vehicles[MAX_PLAYERS][playerid] =
{
520, // hydra
593, // dodo
376, // rustler
432}; // rhino

    if( oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER )
    {
    //If they got into a car from being on foot.
        if( GetVehicleModel(GetPlayerVehicleID( playerid )) == vehicles)  //naudoti || masina ||
        {
            if( GetPlayerSkin(playerid) != 27) //naudoti || skinas ||

            {
                //If their skin is not 27
                //Remove them and send message.
                RemovePlayerFromVehicle( playerid );
                SendClientMessage( playerid,0xFF000000, "Noredami vairuoti si transporta turite buti elektriku" );//-1
                return 1;
            }
            else
            {
                SendClientMessage(playerid, 0xFF000000, "Atsisedote i transporta. Jeigu dirbate, tada dirbkite savo darba");
                return 1;
            }
        }
    }
    return 1;
}
Should work. I fixed it
Same i dont know why.
+ I want to make cars and skins for multiple jobs...
If what invite me to skype sa-mp921 ill show you per team viewer
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)