new var = MyFunc(...)? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: new var = MyFunc(...)? (
/showthread.php?tid=91030)
new var = MyFunc(...)? -
Remi-X - 11.08.2009
Hi, i want to know how to make a function with a variable. Like
pawn Код:
new var = SetTimer(blah);
KillTimer(var);
works.
Because i want to do something like this:
pawn Код:
new zone1 = CreateZone(some floats);
IsPlayerInZone(playerid, zone1) ;
DestroyZone(zone1);
How do i do this?
Re: new var = MyFunc(...)? -
paytas - 11.08.2009
You just have to return the value in the function:
Exemple
pawn Код:
new zoneid = -1;
CreateZone()
{
return zoneid++;
}
new zone1 = CreateZone(); //zone1 is zone id 0
new zone2 = Createzone(); //zone2 is zone id 1
Re: new var = MyFunc(...)? -
Remi-X - 12.08.2009
Oke, but when i want to use this function, after i created a zone: (new zone1 = CreateZone(1342.4352, 321.5788, 1345.3564, 341.9043);
pawn Код:
if(IsPlayerInZone(playerid, zone1))
{
if(zoneid == zone1)
{
printf("How do i show the floats out of CreateZone here?");
}
}
Re: new var = MyFunc(...)? -
Donny_k - 12.08.2009
Use arrays.
Re: new var = MyFunc(...)? -
Remi-X - 12.08.2009
..Example? I'm not a scripting god you know, i don't have anything at a post like yours. Sorry
Re: new var = MyFunc(...)? -
Donny_k - 12.08.2009
"scripting god" lmao, ok dude I'm in a good mood so I'll give you an example:
pawn Код:
// used to track the amount of zones created and to pass the current ID back out of the custom function
new iZoneCount = -1;
// used to store the coordinates of your created zones, the slot of the array is it's ID (the first dimension)
new Float:fGangZonesCoords[ >>AMOUNT_HERE<< ][ 4 ];
//in your custom create zone function CreateZone( Float:min_x, Float:max_x, ...................
iZoneCount ++; // increment by one (move to the next zonescoords array slot)
fGangZonesCoords[ iZoneCount ][ 0 ] = min_x; // pass the values to the array
//do this for all four
return iZoneCount; //return the current slot being used, the zones id (the slot in the array)
Re: new var = MyFunc(...)? -
James_Alex - 12.08.2009
why you do this ?
pawn Код:
new Zone1;
new Zone2;
Zone1 = CreateZone...
Zone2 = CreateZone...
why not
pawn Код:
new Zone[15]; // You can change "15" by the maximux zones
Zone[0] = CreateZone...
Zone[1] = CreateZone...
and to destroy all the zones in the same time you can use
pawn Код:
for(new z = 0; z < 15; z ++)
{
DestroyZone(Zone[z]);
}
or this
pawn Код:
if(IsPlayerInZone(playerid, zone1))
{
if(zoneid == zone[0])
{
printf("How do i show the floats out of CreateZone here?");
}
}
...