SA-MP Forums Archive
little bug - 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: little bug (/showthread.php?tid=587559)



little bug - saffierr - 31.08.2015

A little bug, It removes me from every car in the map, while I want it just for the 5 cars from GSF. If you're not a GSF member it removes me from everycar in the map. Please help, how do I change it to just: If you're not a GSF member you cannot drive a GSF vehicle.
PHP код:
public OnPlayerStateChange(playeridnewstateoldstate)
{
    if(
newstate == PLAYER_STATE_DRIVER)
    {
        new 
vehicleid GetPlayerVehicleID(playerid);
        if(
vehicleid == Veh || Veh2 || Veh3 || Veh4 || Veh5)
        {
            if(
PlayerInfo[playerid][MemberGSF] >= || PlayerInfo[playerid][LeaderGSF] >= 1)
            {
                
SendClientMessage(playeridCOLOR_LIMEGREEN"You have entered your organization vehicle!");
            }
            else
            {
                
SendClientMessage(playeridCOLOR_RED"Error: You are not a member of Grove Street Families!");
                
RemovePlayerFromVehicle(playerid);
            }
        }
    }
    return 
1;




Re: little bug - Logofero - 31.08.2015

Quote:
Originally Posted by saffierr
Посмотреть сообщение
A little bug, It removes me from every car in the map, while I want it just for the 5 cars from GSF. If you're not a GSF member it removes me from everycar in the map. Please help, how do I change it to just: If you're not a GSF member you cannot drive a GSF vehicle.
PHP код:
public OnPlayerStateChange(playeridnewstateoldstate)
{
    if(
newstate == PLAYER_STATE_DRIVER)
    {
        new 
vehicleid GetPlayerVehicleID(playerid);
        if(
vehicleid == Veh || Veh2 || Veh3 || Veh4 || Veh5)
        {
            if(
PlayerInfo[playerid][MemberGSF] >= || PlayerInfo[playerid][LeaderGSF] >= 1)
            {
                
SendClientMessage(playeridCOLOR_LIMEGREEN"You have entered your organization vehicle!");
            }
            else
            {
                
SendClientMessage(playeridCOLOR_RED"Error: You are not a member of Grove Street Families!");
                
RemovePlayerFromVehicle(playerid);
            }
        }
    }
    return 
1;

PHP код:

new bool:v_clan_gsf[MAX_VEHICLES];
public 
OnGameModeInit() {
       
//... = CreateVehicle();
       
v_clan_gsf[1] = true// Vehicle ID 1 in clan GSF
       
v_clan_gsf[20] = true// etc..
       
v_clan_gsf[10] = true// EOF Vehicles of clan GSF
       
return true;
}
public 
OnPlayerStateChange(playeridnewstateoldstate)
{
    if(
newstate == PLAYER_STATE_DRIVER)
    {
        new 
vehicleid GetPlayerVehicleID(playerid);
        if(
v_clan_gsf[vehicleid])
        {
            if(
PlayerInfo[playerid][MemberGSF] >= && PlayerInfo[playerid][LeaderGSF] >= 1)
            {
                
SendClientMessage(playeridCOLOR_LIMEGREEN"You have entered your organization vehicle!");
            }
            else
            {
                new
                     
Float:xFloat:yFloat:z
                
;
                
GetPlayerPos(playeridxyz);
                
SendClientMessage(playeridCOLOR_RED"Error: You are not a member of Grove Street Families!");
                
SetPlayerPos(playeridxyz);
                
// Or RemovePlayerFromVehicle(playerid);
            
}
        }
    }
    return 
1;




Re: little bug - saffierr - 31.08.2015

Thanks, it's been solved.
what was the difference between yours and mine, lol...? what was the big deal?


Re: little bug - Logofero - 01.09.2015

Quote:
Originally Posted by saffierr
Посмотреть сообщение
Thanks, it's been solved.
what was the difference between yours and mine, lol...? what was the big deal?
Difference. For routine operations, and storage arrays are better than just variables. You will be comfortable working with an array - it will come with experience.


Re: little bug - saffierr - 01.09.2015

Yeah I hope so, but why do I have to use Floats lol...
How is that needed?


Re: little bug - Logofero - 01.09.2015

Quote:
Originally Posted by saffierr
Посмотреть сообщение
Yeah I hope so, but why do I have to use Floats lol...
How is that needed?
And where did you see Float
bool - a bit variable, the fastest of all existing, used for logical comparison. It has only two states, 1 - true, 2 - false


Re: little bug - saffierr - 01.09.2015

Not in the bool.

In the OnPlayerStateChange
You added Floats


Re: little bug - Logofero - 01.09.2015

Quote:
Originally Posted by saffierr
Посмотреть сообщение
Not in the bool.

In the OnPlayerStateChange
You added Floats
You about this?

PHP код:
new
                     
Float:xFloat:yFloat:z
                
;
                
GetPlayerPos(playeridxyz);
                
SendClientMessage(playeridCOLOR_RED"Error: You are not a member of Grove Street Families!");
                
SetPlayerPos(playeridxyz); 
This is the case unless the player withdraws from car. If call SetPlayerPos it will be removed from car. This Alt. RemovePlayerFromVehicle


Re: little bug - saffierr - 01.09.2015

Exactly, why are those Floats needed was my simple question.


Re: little bug - SoFahim - 02.09.2015

For, GetPlayerPos and SetPlayerPos . you can see it.