Useful Functions and Callbacks Re-release
#1

Hi scripters,

maybe you also recognized that the "Useful Functions/Callbacks" from Sacky doesn't work. So I took the initiative and edited the whole uf.inc file.
it took me a week to renew the functions and callbacks. i edited many functions and callbacks, which had small bugs, and i added many functions and callbacks of my own.
i also added a few callbacks by DracoBlue and Rafelder.
i asked Sacky for permission, but he didn't answered me so i hope he doesn't mind that i re-release the collection of useful functions and callbacks, which were once gathered by him.
It also includes the functions of dutils.inc by DracoBlue, because running both in 2 files didn't work.


Download it:




Installation:
  • download the ZIP-file and extract the uf.inc to \pawno\include\ (or wherever the a_samp.inc is)
  • insert #include <uf> at the bottom of your a_samp.inc (really at the bottom, not just under the others #include ...)
  • insert in your script #include <a_samp> (probably already done)
  • insert into public OnGameModeInit() the command GameModeInit(), e.g.:
    • public OnGameModeInit()
      {
      GameModeInit();
      // and then your script...
Notation:
Quote:

There some extension functions, like TogglePlayerControllable2(), which were quite the same as the original function, like TogglePlayerControllable(), with the difference that some other functions does NOT work if you don't use the extansion.
Because I needed the callback OnVehicleSpawn(vehicleid) you have to use OnVehicleSpawn2(vehicleid,dynamic) (dynamic means, the vehicle was spawned to a new userdefined spawnpoint, so you can ignore it, if you didn't use the function SetVehicleSpawnPos().

On entering a vehicle the name of it will appear for 3 seconds at the right bottom of your screen.


I've started writing articles for each command, here you can look for the functions and callbacks: http://streetplaya.hopto.org/SAMP_Wi...Functions.html.
Till I've finished this you can search in the uf.inc-file for the command (commands begin with "stock ").
If anybody still find a bug please report it to me (PM or larcius.pc@web.de)

P.S.: Please post your new commands and callbacks here, so I can insert them into the uf.inc

_________________________________________________
Thanks to all people, who published their functions and callbacks:
  • Alex "******" Cole
  • Jan "DracoBlue" Schьtze
  • Gabriel "Larcius" Cordes
  • Rafelder
  • Mike
  • Slick
  • Allan
  • SidViciousII
  • Darkrealm
  • El Presy
  • Spectre
  • mabako
  • Sacky
  • Boss
  • Toxic
  • dyraXon
  • yellowblood
  • 50p
  • rapidZ
  • Tratulla
  • Kamazy
  • Simon
  • yom
  • Betamaster
  • Peter
  • kool
  • Hellomy
Reply
#2

Are you sure you tested it?

I don't think
pawn Код:
stock GetPlayerId(playername[])
{
  return return GetPlayerID(partofname[],0);
}
will work..


Why do you return a distance like 999999999999999.0 if invalid distance? Invalid distance should be a negative number, like -1.0.
And 999999999999999.0 is not even a valid float, as well as 999999999999999 is not a valid number.
Reply
#3

let me explain you why i decided to return BIG_FLOAT instead of -1.0:
if you want to know if for example player 2 is at most 200.0 metres away from you (playerid=0)
Код:
if(GetDistanceBetweenPlayers(0,2)<=200.0)
{
   SendClientMessage(0, 0xFFFFFFFF, "player 2 is at most 200.0 m away from you");
}
now think about the case, that player 2 i not connected. in this case it returns BIG_FLOAT.
so we have:
Код:
if(999999999999999.0<=200.0) //that's not true, so we won't get the message
{
   SendClientMessage(0, 0xFFFFFFFF, "player 2 is at most 200.0 m away from you");
}
if the function would return -1.0 we would have:
Код:
if(-1.0<=200.0) //that's true, so we will get the message, although player 2 is not connected
{
   SendClientMessage(0, 0xFFFFFFFF, "player 2 is at most 200.0 m away from you");
}
of course we could add something like this
Код:
if(GetDistanceBetweenPlayers(0,2)<=200.0 && GetDistanceBetweenPlayers(0,2)!=-1.0)
{
//and so on
}
but in my opinion its easier to return BIG_FLOAT, so others don't have to add " && GetDistanceBetweenPlayers(0,2)!=-1.0" to each if-condition.
why are BIG_FLOAT and BIG_INT not valid float and integer? are they too big?
if so please tell me max_float and max_int

the other thing you mentioned: yes, i didn't recognized that, but i already updated the file with only one return.
there could still be a few small bugs, because i can't check 4288 lines without making any mistakes (errare humanum est!!!).

best wishes
larcius
Reply
#4

Yes, BIG_FLOAT and BIG_INT are too big, use printf("%f %d", BIG_FLOAT, BIG_INT); to see what's wrong. The values shouldn't be bigger than the value of cellmax.

For testing, remove all 'stock' prefixes and be sure to test all functions you provide

Also, there are tons of useful functions from the topic of the same name, maybe you should include some of them ?
Reply
#5

thanks for the infinity float. i edited this and defined INF_FLOAT, which will be returned.
Код:
const Float:INF_FLOAT=Float:0x7F800000;
// and in the function:
return INF_FLOAT;
can i define INF_INT like this:
Код:
#define INF_INT 0x7F800000
to yom:
i know there many functions at the topic, which i wanted to add. but as i can see there are only a few persons, who downloaded the uf.inc so i don't do so much work for maybe 10 persons.
i just removed all stock for testing and i all i got are "warning 203: symbol is never used: ...", so everything should work.
Reply
#6

yes, ok, so it is not possible to define an infinity integer?
i understand the difference between Float:... and float(...);
Float will just declare a var to an Float-var and float(...) will convert a var to an float-var
Reply
#7

Hmm Nice 1 but still...


MR.KONRADS
Reply
#8

i know its a old topic but i have a question

you said on wiki at this page https://sampwiki.blast.hk/wiki/AddStaticPickup2

Quote:

It strongly recommend to use AddStaticPickup2 instead of AddStaticPickup!

why?

they look the same to me
Reply
#9

using AddStaticPickup() instead of AddStaticPickup2() do not save the coords and other datas. that means these functions won't work:

pawn Код:
IsPickupConnected(pickupid);
GetPickups();

//these callbacks won't work, too

public OnPlayerPickupItem(playerid,pickupid,modelid,type);
public OnPickupRespawn(pickupid,modelid);
use CreatePickup2() and DestroyPickup2() instead of the old functions.
Reply
#10

1 Prob, when I am trying to compile with SA-MP 0.2X I get a rid of errors and warnings:
[code=Errors and Warnings]
C:\Users\Alive\Desktop\alive's server\pawno\include\uf.inc(442) : error 017: undefined symbol "MAX_PLAYERS"
C:\Users\Alive\Desktop\alive's server\pawno\include\uf.inc(482) : error 017: undefined symbol "MAX_PLAYERS"
C:\Users\Alive\Desktop\alive's server\pawno\include\uf.inc(484) : error 017: undefined symbol "MAX_PLAYERS"
C:\Users\Alive\Desktop\alive's server\pawno\include\uf.inc(484) : error 009: invalid array size (negative, zero or out of bounds)
C:\Users\Alive\Desktop\alive's server\pawno\include\uf.inc(485) : error 017: undefined symbol "MAX_PLAYERS"
C:\Users\Alive\Desktop\alive's server\pawno\include\uf.inc(486) : error 017: undefined symbol "MAX_PLAYERS"
C:\Users\Alive\Desktop\alive's server\pawno\include\uf.inc(48 : error 017: undefined symbol "MAX_VEHICLES"
C:\Users\Alive\Desktop\alive's server\pawno\include\uf.inc(489) : error 017: undefined symbol "MAX_PLAYERS"
C:\Users\Alive\Desktop\alive's server\pawno\include\uf.inc(490) : error 017: undefined symbol "MAX_PLAYERS"
C:\Users\Alive\Desktop\alive's server\pawno\include\uf.inc(497) : error 017: undefined symbol "TextDrawCreate"
C:\Users\Alive\Desktop\alive's server\pawno\include\uf.inc(497) : warning 215: expression has no effect
C:\Users\Alive\Desktop\alive's server\pawno\include\uf.inc(497) : warning 215: expression has no effect
C:\Users\Alive\Desktop\alive's server\pawno\include\uf.inc(497) : warning 215: expression has no effect
C:\Users\Alive\Desktop\alive's server\pawno\include\uf.inc(497) : error 001: expected token: ";", but found ")"
C:\Users\Alive\Desktop\alive's server\pawno\include\uf.inc(497) : error 029: invalid expression, assumed zero
C:\Users\Alive\Desktop\alive's server\pawno\include\uf.inc(497) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


13 Errors.

[/code]

Pleas, help me?
Reply
#11

Put #include a_samp before #include uf
Reply
#12

Thanks, helped
Reply
#13

Hi
I have some problems with this include:

Код:
C:\Program Files (x86)\GTA\GTA San Andreas 1\pawno\include\uf.inc(43) : warning 201: redefinition of constant/macro (symbol "MAX_PICKUPS")
C:\Program Files (x86)\GTA\GTA San Andreas 1\pawno\include\uf.inc(533) : warning 219: local variable "controllable" shadows a variable at a preceding level
C:\Program Files (x86)\GTA\GTA San Andreas 1\pawno\include\uf.inc(803) : error 035: argument type mismatch (argument 2)
C:\Program Files (x86)\GTA\GTA San Andreas 1\gamemodes\Simon1.pwn(83) : error 025: function heading differs from prototype
C:\Program Files (x86)\GTA\GTA San Andreas 1\gamemodes\Simon1.pwn(465) : error 035: argument type mismatch (argument 1)
C:\Program Files (x86)\GTA\GTA San Andreas 1\gamemodes\Simon1.pwn(612) : error 021: symbol already defined: "OnVehicleSpawn"
C:\Program Files (x86)\GTA\GTA San Andreas 1\gamemodes\Simon1.pwn(1323) : error 025: function heading differs from prototype
C:\Program Files (x86)\GTA\GTA San Andreas 1\gamemodes\Simon1.pwn(1324) : error 021: symbol already defined: "GetPlayerID"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)