[Include] e_static ● Easily check player states ● Version 1
#1

e_static
Version 1
Update: 9 June, 2013








Description
Hello friends. This is my simple player state checker. Many scripts need function related to player states like have the player spawned OR Is the player dead or God etc... So this native helps you to do that in your script easily. All you have to do is download this include, wait just read the further instillations and steps to use this include. Thanks and remember , this is my first include.









Natives
pawn Код:
/*
native IsPlayerSpawned(playerid);
native IsPlayerDead(playerid);
native IsPlayerInClassSelection(playerid);
native IsPlayerOnBike(playerid);
native IsPlayerInCar(playerid);
native IsPlayerInBoat(playerid);
native IsPlayerInHelicopter(playerid);
native IsPlayerInAircraft(playerid);
native IsPlayerAfk(playerid);
native IsPlayerInjured(playerid);
native IsPlayerGod(playerid);
native IsPlayerMale(playerid);
native IsPlayerFemale(playerid);
native IsPlayerInWater(playerid);
native IsPlayerOnLand(playerid);
*/
  • IsPlayerSpawned(playerid);
Function: Checks whether the player is spawned or not.
  • IsPlayerDead(playerid);
Function: Checks whether the player is dead or not.
  • IsPlayerInClassSelection(playerid);
Function: Checks whether the player is selecting class or not.
  • IsPlayerOnBike(playerid);
Function: Checks whether the player is on bike or not.
  • IsPlayerInCar(playerid);
Function: Checks whether the player is in car or not.
  • IsPlayerInBoat(playerid);
Function: Check whether the player is in boat or not.
  • IsPlayerInHelicopter(playerid);
Function: Check whether the player is in helicopter or not.
  • IsPlayerInAircraft(playerid);
Function: Check whether the player is in any aircraft or not.
  • IsPlayerAfk(playerid);
Function: Check whether the player away from keyboard (AFK) or not.
  • IsPlayerInjured(playerid);
Function: Check whether the player having low hp or not.
  • IsPlayerGod(playerid);
Function: Check whether the player having hp more than 100 or not.
  • IsPlayerMale(playerid);
Function: Check whether the player having male skin or not.
  • IsPlayerFemale(playerid);
Function: Check whether the player having female skin or not.
  • IsPlayerInWater(playerid);
Function: Check whether the player is in water or not.
  • IsPlayerOnLand(playerid);
Function: Check whether the player is on land or not.








Download
PasteBin
Reply
#2

Very useful, good work.
Reply
#3

Have you tested it? Most of it doesn't work properly.
Reply
#4

Quote:
Originally Posted by Basssiiie
Посмотреть сообщение
Have you tested it? Most of it doesn't work properly.
Actually i didn't tested them, i got my GTA Sa. directory deleted so i couldn't. And i am new to includes.
Tell me what am i doing wrong so that i can fix it.

Thanks for the feed back.
Reply
#5

pawn Код:
Hook:P_OnPlayerUpdateEx
that's just one big enough reason to not use this D:
Reply
#6

pawn Код:
if(IsPlayerMale(playerid) && IsPlayerFemale(targetid)) sexytime = STRAIGHT_SEX;
else if(IsPlayerMale(playerid) && IsPlayerMale(targetid)) sexytime = GAY_SEX;
else if(IsPlayerFemale(playerid) && IsPlayerFemale(targetid)) sexytime = LESBIAN_SEX;
Reply
#7

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
pawn Код:
if(IsPlayerMale(playerid) && IsPlayerFemale(targetid)) sexytime = STRAIGHT_SEX;
else if(IsPlayerMale(playerid) && IsPlayerMale(targetid)) sexytime = GAY_SEX;
else if(IsPlayerFemale(playerid) && IsPlayerFemale(targetid)) sexytime = LESBIAN_SEX;
Does that code works... LOLZzz
Reply
#8

Quote:
Originally Posted by Excel™
Посмотреть сообщение
Does that code works... LOLZzz
Sure you just need to make sure those defines are declared

#define STRAIGHT_SEX 11
#define GAY_SEX 455
#define LESBIAN_SEX 69

You could even check for 3-somes, orgies and gangbangs!

Suggestion here.

pawn Код:
stock IsPlayerOnBike(playerid)
{
        if(!IsPlayerInAnyVehicle(playerid)) return false;
        new
            Bikes[12]=
            {   581,509,481,421,462,510,463,522,461,448,586,468 },
                vehicleid=GetPlayerVehicleID(playerid);
        for(new i = 0; i < 12; i++)
        {
        if(GetVehicleModel(vehicleid) == Bikes[i])
                {   return true;        } else return false;
        }
}
pawn Код:
stock IsPlayerOnBike(playerid)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        switch(GetPlayerVehicleID(GetVehicleModel(vehicleid)))
        {
            case 581: return true;
            case 509: return true;
            case 481: return true;
            case 421: return true;
            case 462: return true;
            case 510: return true;
            case 463: return true;
            case 522: return true;
            case 461: return true;
            case 448: return true;
            case 586: return true;
            case 468: return true;
        }
    }
    return false;
}
No need for looping or calling GetVehicleModel(vehicleid) multiple times this way.
Reply
#9

One of the problems is here (and it's in every IsPlayerOn-vehicle function):
pawn Код:
stock IsPlayerOnBike(playerid)
{
        if(!IsPlayerInAnyVehicle(playerid)) return false;
        new
            Bikes[12]=
            {   581,509,481,421,462,510,463,522,461,448,586,468 },
                vehicleid=GetPlayerVehicleID(playerid);
        for(new i = 0; i < 12; i++)
        {
        if(GetVehicleModel(vehicleid) == Bikes[i])
                {   return true;        } else return false;
        }
}
It will only check if the player model is equal to the first model in the array, then it quits the function. Please, don't release stuff you haven't tested. It bothers me a lot when people do this. Someone could be struggling for days to find out why his script doesn't work, until he discovers out it's your script that is the actual problem. That's very annoying! That guy trusted you to delivered functions that actually work!


Also, in addition to what Pottus suggested, this would even be better:
pawn Код:
stock IsPlayerOnBike(playerid)
{
    new veh = GetPlayerVehicleID(playerid);
   
    if (veh)
    {
        switch (GetVehicleModel(veh))
        {
            case 581, 509, 481, 421, 462, 510, 463, 522, 461, 448, 586, 468: return true;
        }
    }
    return false;
}
This way you only call two functions, instead of three in Pottus' version. Besides that, it looks much cleaner and avoids repetitive code.
Reply
#10

Quote:
Originally Posted by Excel™
Посмотреть сообщение
Does that code works... LOLZzz
Quote:
Originally Posted by Basssiiie
Посмотреть сообщение
One of the problems is here (and it's in every IsPlayerOn-vehicle function):
pawn Код:
stock IsPlayerOnBike(playerid)
{
        if(!IsPlayerInAnyVehicle(playerid)) return false;
        new
            Bikes[12]=
            {   581,509,481,421,462,510,463,522,461,448,586,468 },
                vehicleid=GetPlayerVehicleID(playerid);
        for(new i = 0; i < 12; i++)
        {
        if(GetVehicleModel(vehicleid) == Bikes[i])
                {   return true;        } else return false;
        }
}
It will only check if the player model is equal to the first model in the array, then it quits the function. Please, don't release stuff you haven't tested. It bothers me a lot when people do this. Someone could be struggling for days to find out why his script doesn't work, until he discovers out it's your script that is the actual problem. That's very annoying! That guy trusted you to delivered functions that actually work!


Also, in addition to what Pottus suggested, this would even be better:
pawn Код:
stock IsPlayerOnBike(playerid)
{
    new veh = GetPlayerVehicleID(playerid);
   
    if (veh)
    {
        switch (GetVehicleModel(veh))
        {
            case 581, 509, 481, 421, 462, 510, 463, 522, 461, 448, 586, 468: return true;
        }
    }
    return false;
}
This way you only call two functions, instead of three in Pottus' version. Besides that, it looks much cleaner and avoids repetitive code.
Your right IsPlayerInAnyVehicle(playerid)) is useless check, I should have noticed it as for the switch() your method is a better way to do it in terms of compactness but I like to list each out on it's own line it's easier for me to read/update if I need to. When you write a lot of functions that have a switch() compacting them down like that can be very confusing since none of the case are marked by comments it's good to keep things easily editable even if it is repetitive.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)