[Include] rFunctions© v2.R [Updated]
#1

rFunctions© 3.R



Introduction

In this include there are total 66 (updated 3.R) functions, which you can use while scripting roleplay/freeroam/party or any other kind of server.Let us proceed with the functions below.



Functions

SendRangeMessageToPlayer(playerid, Float:Range, Float:x, Float:y, Float:z, color, text[])

This function will send a message to the player who is within the specified range.



SendRangeMessageToAll(Float:Range, Float:x, Float:y, Float:z, color, text[])

This function will send messages to all player who are present within the specified range.



GivePlayerRangeWeapon(playerid, weaponid,ammo, Float:Range, Float:x, Float:y, Float:z)

This function gives a weapon to a player who is within a specified range.



RangeKick(playerid, Float:Range, Float:x, Float:y, Float:z)

This function kicks the players who enters a specified area.



RangeKill(playerid, Float:Range, Float:x, Float:y, Float:z)

This function prevents the player from entering a specified range/area.



TeleportAllForEvent(Float:x, Float:y, Float:z, virtualworld, interior, bool:weaponallowance)

This functions teleports each and every connected player to a specified position and the weaponallowance boolean parameter is to disable and enable player weapon when they spawn to that position.
true = enable
false = disable



DuetTeleport(playerid, partnerid, Float:x, Float:y, Float:z)

This function teleports 2 players together to a position.There is a special feature in this function that, they will not get a spawn collapse bug, which means all players will not get stuck into each other.



TripletTeleport(playerid, partnerid1, partnerid2, Float:x, Float:y, Float:z, virtualworld, interior)

Same as above function, just teleports 3 players instead of 2.



GroupTeleport(playerid, Float:x, Float:y, Float:z,virtualworld, interior)

This function lets you and your friends teleport together, but your friends should be present within 15.0 range from you. No spawn collapse bug here too.



GetPlayerHeightDifference(playerid, heightid);

This function will let you know the height difference between you and any other player who is at position higher than you.Returns a float value.



GivePlayerWeapons(playerid, weaponid1, ammo1,weaponid2, ammo2,weaponid3, ammo3,weaponid4, ammo4,weaponid5, ammo5)

This funtion is used to give 5 weapons together to a player.



SetPlayerWeapon(playerid,weaponid,ammo)

This function removes all the weapons and gives you a weapon according to your wish.



SetPlayerWeapons(playerid, weaponid1, ammo1,weaponid2, ammo2,weaponid3, ammo3,weaponid4, ammo4,weaponid5, ammo5)

This function removes all the weapons and gives you 5 weapons according to your choice.This function is very beneficial for DeathMatches as it removes all the weapons and gives you specified weapons.

GetPlayerHealthDifference(playerid)

This function gets the amount of health loss from the actual health i.e. 100.0. Return loss of health as a float value.



FullFillPlayerHealth(playerid)

This function full fills the amount of health loss.Good for Roleplay scripter.(Hospital)



Update 2.R (6/30/2014)

Added some weapon functions, skydiving functions and co-ordinates functions.

Weapons

GiveBrassKnucle(playerid)

GiveGolfClub(playerid)

GiveNightStick(playerid)

GiveKnife(playerid)

GiveBat(playerid)

GiveShovel(playerid)

GivePoolCue(playerid)

GiveKatana(playerid)

GiveChainsaw(playerid)

GiveDildo(playerid)

GiveDildo2(playerid)

GiveVibrator(playerid)

GiveVibrator2(playerid)

GiveFlower(playerid)

GiveCane(playerid)

GiveGrenade(playerid, ammo)

GiveTearGas(playerid, ammo)

GiveMolotov(playerid , ammo)

GiveColt45(playerid, ammo)

GiveSilenced(playerid, ammo)

GiveDeagle(playerid, ammo)

GiveShotgun(playerid, ammo)

GiveSawn(playerid, ammo)

GiveCombat(playerid, ammo)

GiveUzi(playerid, ammo)

GiveMP5(playerid, ammo)

GiveAK47(playerid, ammo)

GiveM4(playerid, ammo)

GiveTec9(playerid, ammo)

GiveRifle(playerid, ammo)

GiveSniper(playerid, ammo)

GiveRPG(playerid, ammo)

GiveFlameThrower(playerid)

GiveMini(playerid, ammo)

GiveSprayCan(playerid)

GiveFireExt(playerid)

GiveCamera(playerid, ammo)

GivePara(playerid)


Skydiving

DuetDive(playerid, partnerid, Float:height)

This function is used for 2 player skydive,you can set the height.


TripletDive(playerid, partnerid1, partnerid2, Float:height)

This function is used for 3 player skydive,you can set the height.


GroupDive(playerid,Float:Range, Float:height)

I made filterscript on this before, but now it's a function.This function checks the player present in a range specified by you in the "Range" parameter,you can set the height.


Co-ordinates

GetX(playerid)

Return the value of "X" co-ordinate.

GetY(playerid)

Return the value of "Y" co-ordinate.

GetZ(playerid)

Return the value of "Z" co-ordinate.


Update 3.R (7/8/2014)

Added 5 new useful functions and enhanced few teleport functions by adding virtualworld parameter and interior parameter.

SetRangeSkin(playerid, skinid, Float:Range, Float:x, Float:y, Float:z)

Sets the skin of the player who enters a specified position.

In the video below, the function is called under OnPlayerUpdate. This video demonstrates that as soon as we enter a specified range our skin gets changed to a specified skin.

https://www.youtube.com/watch?v=ZnbOyGN9bz4

AntiVehicleRange(playerid, Float:Range, Float:x, Float:y, Float:z)

This function does not let a player enter a specified range with a vehicle.

SetAllSkill(playerid, level)

Sets all type of weapon skills of a player.You must specify skill level between 0-999.

EnableGod(playerid)

Gives player god mode.

DisableGod(playerid)

Removes god mode.

SnatchWeaponFromTarget(playerid, targetid) (Special)

Disarms the targetid holding a specific weapon and arms the playerid with that weapon.
Note: Ammo will not get changed while snatching i.e. if the target has 15 ammo and you snatched that weapon from him, the ammo will remain 15 after snatching.

Total Include Functions

SendRangeMessageToPlayer(playerid, Float:Range, Float:x, Float:y, Float:z, color, text[])
SendRangeMessageToAll(Float:Range, Float:x, Float:y, Float:z, color, text[])
GivePlayerRangeWeapon(playerid, weaponid,ammo, Float:Range, Float:x, Float:y, Float:z)
RangeKick(playerid, Float:Range, Float:x, Float:y, Float:z)
RangeKill(playerid, Float:Range, Float:x, Float:y, Float:z)
TeleportAllForEvent(Float:x, Float:y, Float:z, virtualworld, interior, bool:weaponallowance)
DuetTeleport(playerid, partnerid, Float:x, Float:y, Float:z, virtualworld, interior)
TripletTeleport(playerid, partnerid1, partnerid2, Float:x, Float:y, Float:z, virtualworld, interior)
GroupTeleport(playerid, Float:x, Float:y, Float:z, virtualworld, interior)
GetPlayerHeightDifference(playerid, heightid);
GivePlayerWeapons(playerid, weaponid1, ammo1,weaponid2, ammo2,weaponid3, ammo3,weaponid4, ammo4,weaponid5, ammo5)
SetPlayerWeapon(playerid,weaponid,ammo)
SetPlayerWeapons(playerid, weaponid1, ammo1,weaponid2, ammo2,weaponid3, ammo3,weaponid4, ammo4,weaponid5, ammo5)
GiveBrassKnucle(playerid)
GiveGolfClub(playerid)
GiveNightStick(playerid)
GiveKnife(playerid)
GiveBat(playerid)
GiveShovel(playerid)
GivePoolCue(playerid)
GiveKatana(playerid)
GiveChainsaw(playerid)
GiveDildo(playerid)
GiveDildo2(playerid)
GiveVibrator(playerid)
GiveVibrator2(playerid)
GiveFlower(playerid)
GiveCane(playerid)
GiveGrenade(playerid, ammo)
GiveTearGas(playerid, ammo)
GiveMolotov(playerid , ammo)
GiveColt45(playerid, ammo)
GiveSilenced(playerid, ammo)
GiveDeagle(playerid, ammo)
GiveShotgun(playerid, ammo)
GiveSawn(playerid, ammo)
GiveCombat(playerid, ammo)
GiveUzi(playerid, ammo)
GiveMP5(playerid, ammo)
GiveAK47(playerid, ammo)
GiveM4(playerid, ammo)
GiveTec9(playerid, ammo)
GiveRifle(playerid, ammo)
GiveSniper(playerid, ammo)
GiveRPG(playerid, ammo)
GiveFlameThrower(playerid)
GiveMini(playerid, ammo)
GiveSprayCan(playerid)
GiveFireExt(playerid)
GiveCamera(playerid, ammo)
GivePara(playerid)
GetPlayerHealthDifference(playerid)
FullFillPlayerHealth(playerid)
DuetDive(playerid, partnerid, Float:height)
TripletDive(playerid, partnerid1, partnerid2, Float:height)
GroupDive(playerid,Float:Range, Float:height)
GetX(playerid)
GetY(playerid)
GetZ(playerid)
SetRangeSkin(playerid, skinid, Float:Range, Float:x, Float:y, Float:z)
AntiVehicleRange(playerid, Float:Range, Float:x, Float:y, Float:z)
SetAllSkill(playerid,level)
EnableGod(playerid)
DisableGod(playerid)
SnatchWeaponFromTarget(playerid, targetid) (Special)




Version

Version 3.R



GitHub

GitHub- rFunctions



Download

rFunc.inc v1.R

rFunc2.inc v2.R

rFunc3.inc v3.R

Note: I'll suggest you to use v3.R as it is more enhanced than the previous versions.
Reply
#2

Nice.I'm gonna use some of them.
Reply
#3

thses are OK
but some of them are useless
the useless functions are--

FullFillPlayerHealth(playerid) [ we can simply do SetPlayerHealth(playerid, 100); for it]

RangeKick(playerid, Float:Range, Float, Float:y, Float:z) [why would anyone do that]

TeleportAllForEvent(Float, Float:y, Float:z,bool:weaponallowance) [no use of teleporting all players at a single point only will cause lag][an some players may also not wanna participate]

GivePlayerRangeWeapon(playerid, weaponid,ammo, Float:Range, Float, Float:y, Float:z) [ i dont think anyone will use that]
Reply
#4

Quote:

If you find any bugs PM me at foryms.sa-mp.com.

I Think you must fix your typo.

----

pawn Код:
stock SendRangeMessageToPlayer(playerid, Float:Range, Float:x, Float:y, Float:z, color, text[])
{
    if(IsPlayerInRangeOfPoint(playerid,Range,x,y,z))
        {
            SendClientMessage(i,color,text);
        }
}
I Think it's un-compilable!

Fixed one (by me):
pawn Код:
// playerid == prevent the player to send.
// Function name is too long. but you can change it.
stock MessageToPlayersInRangeOfPoint(playerid, Float:x, Float:y, Float:z, Float:range, color, const message[])
{
    new
        ret = 0;

    for(new i = 0; i != MAX_PLAYERS; ++i)
    {
        if(IsPlayerInRangeOfPoint(i, range, x, y, z) && i != playerid)
        {
            SendClientMessage(i, color, message);
            ret++;
        }
    }
    return ret;
}

----

Why you want to forward Stock functions?
pawn Код:
forward Float:GetPlayerHeightDifference(playerid, heightid);
Reply
#5

Very good and useful include. I'm gonna use this. Thank you so much.
Reply
#6

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
thses are OK
but some of them are useless
the useless functions are--

FullFillPlayerHealth(playerid) [ we can simply do SetPlayerHealth(playerid, 100); for it]

RangeKick(playerid, Float:Range, Float, Float:y, Float:z) [why would anyone do that]

TeleportAllForEvent(Float, Float:y, Float:z,bool:weaponallowance) [no use of teleporting all players at a single point only will cause lag][an some players may also not wanna participate]

GivePlayerRangeWeapon(playerid, weaponid,ammo, Float:Range, Float, Float:y, Float:z) [ i dont think anyone will use that]
RangeKick is useful, when player enter "pay 'n' spray" or tuning garage. Of course you can use "If(!IsPlayerInRangeOfPoint)" and than Kick(playerid);, but Rangekick is good too.
Reply
#7

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
thses are OK
but some of them are useless
the useless functions are--

FullFillPlayerHealth(playerid) [ we can simply do SetPlayerHealth(playerid, 100); for it]

RangeKick(playerid, Float:Range, Float, Float:y, Float:z) [why would anyone do that]

TeleportAllForEvent(Float, Float:y, Float:z,bool:weaponallowance) [no use of teleporting all players at a single point only will cause lag][an some players may also not wanna participate]

GivePlayerRangeWeapon(playerid, weaponid,ammo, Float:Range, Float, Float:y, Float:z) [ i dont think anyone will use that]
Fullfill commands are for medic in roleplay servers, like if they have only few blood bags.

Event or admin announcement you can say, which will be compulsory for players to attend.

And GivePlayerRangeWeapon is good for roleplay servers if you know how and where to use it.
Reply
#8

Quote:
Originally Posted by iFarbod
Посмотреть сообщение
I Think you must fix your typo.

----

pawn Код:
stock SendRangeMessageToPlayer(playerid, Float:Range, Float:x, Float:y, Float:z, color, text[])
{
    if(IsPlayerInRangeOfPoint(playerid,Range,x,y,z))
        {
            SendClientMessage(i,color,text);
        }
}
I Think it's un-compilable!

Fixed one (by me):
pawn Код:
// playerid == prevent the player to send.
// Function name is too long. but you can change it.
stock MessageToPlayersInRangeOfPoint(playerid, Float:x, Float:y, Float:z, Float:range, color, const message[])
{
    new
        ret = 0;

    for(new i = 0; i != MAX_PLAYERS; ++i)
    {
        if(IsPlayerInRangeOfPoint(i, range, x, y, z) && i != playerid)
        {
            SendClientMessage(i, color, message);
            ret++;
        }
    }
    return ret;
}

----

Why you want to forward Stock functions?
pawn Код:
forward Float:GetPlayerHeightDifference(playerid, heightid);
Thanks for informing me about that typo, and my code is correct and I have already tested it.
So no point of using your code.
Reply
#9

Quote:
Originally Posted by Rittik
Посмотреть сообщение
Thanks for informing me about that typo, and my code is correct and I have already tested it.
So no point of using your code.
Call it somewhere in a script, otherwise you cannot see the errors.
Reply
#10

Quote:
Originally Posted by kvann
Посмотреть сообщение
Call it somewhere in a script, otherwise you cannot see the errors.
No errors.
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)