Definition of functions in PAWN
#1

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?

Reply
#2

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

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
:/
Reply
#4

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.
Reply
#5

ok I get it. ty for quick replies
Reply
#6

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)