[Include] Useful Public Call Back's
#5

UPCB.inc
Code:
#include <a_samp>

#if defined _UPCB_included
	#endinput
#endif
#define _UPCB_included
#pragma library UPCB

//=======[ PUBLICS ]======= [ 1-ON / 0=OFF ]
#define PublicHealth 1
#define PublicArmour 1
#define PublicPos 1
#define PublicBebida 1
//------------------------------------------

//Variaveis
new Float:VidaA[MAX_PLAYERS],Float:ColeteA[MAX_PLAYERS],Bebida[MAX_PLAYERS],Vivo[MAX_PLAYERS],Float:PosX[MAX_PLAYERS],Float:PosY[MAX_PLAYERS],Float:PosZ[MAX_PLAYERS];

//Forwards
forward OnPlayerHealthChange(playerid,Float:NewHealth,Float:OldHealth);
forward OnPlayerArmourChange(playerid,Float:NewArmour,Float:OldArmour);
forward OnPlayerPosChange(playerid,Float:NewX,Float:OldX,Float:NewY,Float:OldY,Float:NewZ,Float:OldZ);
forward OnPlayerDrunkLevelChange(playerid,NewDrunkLevel,OldDrunkLevel);

stock AtivarUPCB()
{
    if(PublicHealth==1) {SetTimer("TimerVida",1000,true);}
	if(PublicArmour==1) {SetTimer("TimerColete",1000,true);}
	if(PublicPos==1) {SetTimer("TimerPos",1000,true);}
	if(PublicBebida==1) {SetTimer("TimerBebida",1000,true);}
	return 1;
}

public OnPlayerSpawn(playerid) {SetTimerEx("IsVivo",1500,false,"i",playerid);}
public OnPlayerDeath(playerid) {Vivo[playerid]=0;}
public OnPlayerDisconnect(playerid) {Vivo[playerid]=0;}

forward IsVivo(playerid);
public IsVivo(playerid) {Vivo[playerid]=1;}

forward TimerVida();
public TimerVida()
{
	for(new s=0;s<=MAX_PLAYERS;s++) {
	    if(IsPlayerConnected(s)) {
	        new Float:Vida;GetPlayerHealth(s,Vida);
	        if(floatcmp(VidaA[s],Vida)&&Vivo[s]==1) {
				CallRemoteFunction("OnPlayerHealthChange","iff",s,VidaA[s],Vida);
				GetPlayerHealth(s,VidaA[s]);
			}
		}
	}
	return 1;
}
forward TimerColete();
public TimerColete()
{
	for(new s=0;s<=MAX_PLAYERS;s++) {
	    if(IsPlayerConnected(s)) {
	        new Float:Armor;GetPlayerArmour(s,Armor);
	        if(floatcmp(ColeteA[s],Armor)&&Vivo[s]==1) {
				CallRemoteFunction("OnPlayerArmourChange","iff",s,ColeteA[s],Armor);
				GetPlayerArmour(s,ColeteA[s]);
			}
		}
	}
	return 1;
}
forward TimerPos();
public TimerPos()
{
	for(new s=0;s<=MAX_PLAYERS;s++) {
	    if(IsPlayerConnected(s)) {
	        new Float:PosXN,Float:PosYN,Float:PosZN;GetPlayerPos(s,PosXN,PosYN,PosZN);
	        if(floatcmp(PosX[s],PosXN)&&Vivo[s]==1) {
				CallRemoteFunction("OnPlayerPosChange","ifff",s,PosX[s],PosXN,PosY[s],PosYN,PosZ[s],PosZN);
				GetPlayerPos(s,PosX[s],PosY[s],PosZ[s]);
				return 1;
			}
			if(floatcmp(PosY[s],PosYN)&&Vivo[s]==1) {
				CallRemoteFunction("OnPlayerPosChange","ifff",s,PosX[s],PosXN,PosY[s],PosYN,PosZ[s],PosZN);
				GetPlayerPos(s,PosX[s],PosY[s],PosZ[s]);
				return 1;
			}
			if(floatcmp(PosZ[s],PosZN)&&Vivo[s]==1) {
				CallRemoteFunction("OnPlayerPosChange","ifff",s,PosX[s],PosXN,PosY[s],PosYN,PosZ[s],PosZN);
				GetPlayerPos(s,PosX[s],PosY[s],PosZ[s]);
				return 1;
			}
		}
	}
	return 1;
}
forward TimerBebida();
public TimerBebida()
{
	for(new s=0;s<=MAX_PLAYERS;s++) {
	    if(IsPlayerConnected(s)) {
	        new bebida=GetPlayerDrunkLevel(s);
	        if((Bebida[s]!=bebida)&&Vivo[s]==1) {
				CallRemoteFunction("OnPlayerDrunkLevelChange","idd",s,Bebida[s],bebida);
				Bebida[s]=GetPlayerDrunkLevel(s);
			}
		}
	}
	return 1;
}
Reply


Messages In This Thread
Useful Public Call Back's - by SuB_ZeRo0_ - 08.08.2010, 15:44
Re: Useful Public Call Back's - by Hiddos - 08.08.2010, 16:33
Re: Useful Public Call Back's - by [XST]O_x - 08.08.2010, 17:12
Re: Useful Public Call Back's - by Grim_ - 08.08.2010, 17:29
Re: Useful Public Call Back's - by Mike Garber - 10.08.2010, 09:11
Re: Useful Public Call Back's - by DiddyBop - 10.08.2010, 09:20
Re: Useful Public Call Back's - by rbN. - 10.08.2010, 09:30
Re: Useful Public Call Back's - by DiddyBop - 10.08.2010, 09:36
Re: Useful Public Call Back's - by Grim_ - 10.08.2010, 09:37
Re: Useful Public Call Back's - by SuB_ZeRo0_ - 10.08.2010, 17:05

Forum Jump:


Users browsing this thread: 1 Guest(s)