[Include] Little Unneeded Functions
#1

'Little Unneeded Functions'

version 1.1 - by qRighT


This is remaded version from my fallen project that has been more tested and experimented.
If you think that why I haven't just used macros and redefinitions, it is because it's function reliability.
Some of mathematical stuff has been tested with other people who agree that functions are reliable and safe.
Any of founded mistakes and complaints should be written via private message to me.


Functions:

IsCoordNearCoord(Float: x1, Float:y1, Float:z1, Float: x2, Float:y2, Float:z2, Float:radius);
SetPlayerMainStats(playerid, Float:health, Float:armour, money);
GetPlayerMainStats(playerid, &Float:health, &Float:armour, &money);
Kill(playerid);
KillAllPlayers();
KickPlayer(playerid);
BanPlayer(playerid);
KickPlayerEx(playerid, color, const reason[]);
BanPlayerEx(playerid, color, const reason[]);
GiveMoneyToAll(money);
IsPlayerNearPlayer(playerid, targetid, Float:radius);
SetHealthToAll(Float:health);


Explanations:

IsCoordNearCoord - checks if coordinate if close enough to another coordinate with specific radius
SetPlayerMainStats - sets health, armour, and money at once.
Kill - kills player
KillAllPlayers - kills all players
KickPlayer - kicks a player (with fixed using; able to send message and kick at once for example)
BanPlayer - bans a player (with fixed using)
KickPlayerEx - kicks player where you can send message with specific color (with fixed using)
BanPlayerEx - bans player where you can send message with specific color (with fixed using)
GiveMoneyToAll - gives money to all players who are connected
IsPlayerNearPlayer - if player is near other connected player in specific given radius
SetHealthToAll - gives specific health to all connected players


Download:

Click Here

END

If you have questions, feel free to reply! But complaints and reports should be sended via private messages!
More things will come later...
Reply
#2

Your code for checking coordinate is wrong, use the math, somewhere you will end up with negative value. Of mistakes I have created in rush. I have fixed them. Kill is not callback. It is a function that will kill player if needed. I have deleted my last topic and created new one, so that foesn't count as two topics. And what I meant with timers, is that server quickly operates last functions within a second, so I can use timer with 100ms interval length. I have deleted my topic for a reason, and I am pretty much sure that you aren't right every time, ******.
Reply
#3

But what if you have negative x, y, or z axis?
Reply
#4

Well that's kind of true what you are saying. (For complex maths)
Reply
#5

Those floatabs make sure that those complex maths don't get through. As I said I have tested with some people that I trust and who are good at maths.
Reply
#6

I didn't say that I don't get it. I agree with you. Why are you attacking me now? I just said that those little problems with math cannot occur with absolute value, that was just explanation why I use floatabs.
Reply
#7

I just had to make sure nothing goes wrong with coordinates since they can sometime get really messy.
Reply
#8

Quote:
Originally Posted by antixgaming
View Post
I didn't say that I don't get it. I agree with you. Why are you attacking me now?
Because:

Quote:
Originally Posted by antixgaming
View Post
I just said that those little problems with math cannot occur with absolute value
What "little problems", there are no problems at all. This has been proven not just by me, but the ancient Greeks knew this.
Reply
#9

the only useful function I could see is IsCoordNearCoord, the rest is pretty much basic stuff and I wouldn't use an include for those personally.

good job for the effort anyway.
Reply
#10

There is even a function you could use, that would be even faster and simpler xD

PHP код:
stock bool:IsCoordNearCoord(Float:x1Float:y1Float:z1Float:x2Float:y2Float:z2Float:radius)
{
    return 
VectorSize(x1-x2y1-y2z1-z2) <= radius;

//Edit: Y, forgot that
Reply
#11

Quote:
Originally Posted by Kaliber
Посмотреть сообщение
There is even a function you could use, that would be even faster and simpler xD

PHP код:
stock bool:IsCoordNearCoord(Float:x1Float:y1Float:z1Float:x2Float:y2Float:z2Float:radius)
{
    return 
VectorSize(x1-x2y1-y2z1-z2) <= radius*radius;

VectorSize takes the root of the distance so radius shouldn't be multiplied.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)