SA-MP Forums Archive
Definition of functions in PAWN - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Definition of functions in PAWN (/showthread.php?tid=406580)



Definition of functions in PAWN - nestyx - 10.01.2013

hi, i just want to know some stuff...

1.) Which datatypes I can use in PAWN as parameters?

for example:

Код:
function(int i, float f, bool b, String s, char c, char[256] chrarray)
2.) And where is the difference between:

Код:
function(filename[]) // this
Код:
function(const filename[]) // and this
if i call the function with...
Код:
function("ReadMe");
3.) Does the definition of a function in PAWN need the return-typ? If not, why?




Re: PAWN - u3ber - 10.01.2013

1) none, pawn is typeless
2) const = not modifiable
3) no


Re: PAWN - nestyx - 10.01.2013

ok thx and which datatypes i can use in PAWN as parameters? Or do I have to do it
exclusively with Strings like:

Код:
function(filename[]) // this
:/


Re: PAWN - u3ber - 10.01.2013

Quote:
Originally Posted by nestyx
Посмотреть сообщение
ok thx and which datatypes i can use in PAWN as parameters?
Quote:
Originally Posted by arbit
1) none, pawn is typeless
Quote:
Originally Posted by nestyx
Or do I have to do it
exclusively with Strings like:

Код:
function(filename[]) // this
:/
yes.


Re: PAWN - nestyx - 10.01.2013

ok I get it. ty for quick replies


Re: Definition of functions in PAWN - Mauzen - 10.01.2013

I suggest reading some tutorials and looking at existing scripts to get a basic idea of pawn first.
Pawn just uses "cells" as "type". One cell is 4 bytes, and normally its interpreted as signed integer. However there are different "tags" that mark a cell as something special, e.g. as floating point value.

pawn Код:
new Float:floatcell;
// You can also use any custom tags to be used in your functions
// to determine what cells it needs/returns
new CustomTag:customcell;

Float:GetWhatever(Float:x, value) {

}
// defines a function that returns a float-tagged cell,
// while expecting a float and int as parameters

GetWhatever(Float:x, value) {

}
// would also work, though it would then return
// an untagged cell, so an integer, or nothing at all