13.07.2008, 15:17
Hey, i would like to share with you some of the functions i have created in the last time..
i hope it will help you and it will be useful for some of you
Checks if player is in Bicycle.
Next function uses for servers with a factions system...
function checks how much players is online from the chosen faction.
Cleaning the chosen player chat..
Example: ChatCleanup(playerid);
Checks if the car is in the Position you set
Example: if(IsCarInCircle(140,1500.4252,200.5005,5)) { }
Works same as the last function, but this one uses the Z position too.
This function checks if the icon you wrote is valid or not.
Sets the Player X,Y,Z and the facing angle, also sets the interior and virtualworld, Option to for camera behing player (use 0/1)
Same but for vehicles:
*** EDIT , new functions i made..
This one is not mine, but you'll have to use this for the one i made. ( that's the only one i didnt created here.)
That's the function i made, it will avoid server crashes becouse of wrong skin id's.. so every time you use setplayerskin(playerid,skinid)
you will use SetSkin(playerid,skinid) and it will be like a safe function that checks if its valid skin..
[b]Works same as the last functino i made... just with vehicle components.. it checks if the component you wanna add is valid, if it is it will work,
if you wont be valid it will return 1; and it won't work.[/b]
i hope it will help you and it will be useful for some of you
Checks if player is in Bicycle.
pawn Код:
stock IsABicycle(carid)
{
if(GetVehicleModel(carid)==509||GetVehicleModel(carid)==510||GetVehicleModel(carid)==481)
{
return 1;
}
return 0;
}
function checks how much players is online from the chosen faction.
pawn Код:
stock GetFactionPlayers(faction)
{
new mem = 0;
for(new i = 0; i < GetMaxPlayers(); i++)
{
if(IsPlayerConnected(i))
{
if(PLAYERLIST_authed[i])
{
if(PlayerInfo[i][pFaction] == faction)
{
mem++;
}
}
}
}
return mem;
}
pawn Код:
ChatCleanup(playerid, lines = 50)
{
for (new i = 0; i < lines; i++)
{
SendClientMessage(playerid, 0, "\n");
}
}
Checks if the car is in the Position you set
pawn Код:
stock IsCarInCircle(car,Float:x,Float:y,radius)
{
if(GetCarDistanceToPoint(car,x,y) < radius)
{
return 1;
}
return 0;
}
Works same as the last function, but this one uses the Z position too.
pawn Код:
stock IsCarInSphere(vehicleid,Float:x,Float:y,Float:z,radius)
{
if(GetCarDistanceToPointEx(vehicleid,x,y,z) < radius)
{
return 1;
}
return 0;
}
pawn Код:
stock IsValidMapIcon(IconID)
{
if(IconID >= 0 && IconID <= 63)
{
return 1;
}
else
{
return 0;
}
}
Sets the Player X,Y,Z and the facing angle, also sets the interior and virtualworld, Option to for camera behing player (use 0/1)
pawn Код:
stock SetPlayerArea(playerid,Float:x,Float:y,Float:z,Float:angle,Interior,World,Cameraback)
{
SetPlayerPos(playerid,x,y,z);
SetPlayerFacingAngle(playerid,angle);
SetPlayerInterior(playerid,Interior);
SetPlayerVirtualWorld(playerid,World);
if(Cameraback == 1)
{
SetCameraBehindPlayer(playerid);
}
}
pawn Код:
stock SetCarArea(vehicleid,Float:x,Float:y,Float:z,Float:angle,Interior,World)
{
SetVehiclePos(vehicleid,x,y,z);
SetVehicleZAngle(vehicleid,angle);
LinkVehicleToInterior(vehicleid,Interior);
SetVehicleVirtualWorld(vehicleid,World);
}
*** EDIT , new functions i made..
This one is not mine, but you'll have to use this for the one i made. ( that's the only one i didnt created here.)
pawn Код:
stock IsSkinValid(SkinID) return ((SkinID >= 0 && SkinID <= 1)||(SkinID == 2)||(SkinID == 7)||(SkinID >= 9 && SkinID <= 41)||(SkinID >= 43 && SkinID <= 85)||(SkinID >=87 && SkinID <= 118)||(SkinID >= 120 && SkinID <= 148)||(SkinID >= 150 && SkinID <= 207)||(SkinID >= 209 && SkinID <= 272)||(SkinID >= 274 && SkinID <= 288)||(SkinID >= 290 && SkinID <= 299)) ? true:false;
you will use SetSkin(playerid,skinid) and it will be like a safe function that checks if its valid skin..
pawn Код:
stock SetSkin(playerid,skinid)
{
if(!IsSkinValid(skinid))
{
SendClientMessage(playerid,0xA9A9A9FF,"* This is not a valid Skin ID!");
return 1;
}
SetPlayerSkin(playerid,skinid);
return 1;
}
[b]Works same as the last functino i made... just with vehicle components.. it checks if the component you wanna add is valid, if it is it will work,
if you wont be valid it will return 1; and it won't work.[/b]
pawn Код:
stock IsValidComponent(componentid)
{
if(componentid >= 1000 && componentid <= 1193)
{
return 1;
}
else
{
return 0;
}
}
pawn Код:
stock AddCarComponent(vehicleid,componentid)
{
if(!IsValidComponent(componentid))
{
return 1;
}
AddVehicleComponent(vehicleid,componentid);
return 1;
}