SA-MP Forums Archive
Question and help about one function - 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: Question and help about one function (/showthread.php?tid=308338)



Question and help about one function - Artie_Scorpion - 03.01.2012

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?


Re: Question and help about one function - Artie_Scorpion - 03.01.2012

help me!!!


Re: Question and help about one function - Artie_Scorpion - 03.01.2012

help me finally!!!


Re: Question and help about one function - Vrondakis - 03.01.2012

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


Re: Question and help about one function - Artie_Scorpion - 03.01.2012

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... ?


Re: Question and help about one function - Vrondakis - 03.01.2012

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


Re: Question and help about one function - [ABK]Antonio - 03.01.2012

You could also just use the team variable for workers....


Re: Question and help about one function - Artie_Scorpion - 03.01.2012

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...


Re: Question and help about one function - Vrondakis - 03.01.2012

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


Re: Question and help about one function - Artie_Scorpion - 03.01.2012

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