Create- and DestroyObject.
#7

Quote:
Originally Posted by Ihsan-Cingisiz
Посмотреть сообщение
Hmm... I'd like to use this but i never paid attention to PVar, so i don't exactly know how
that works. And what do you exactly mean with the -1, can it just be 10 or something?
-1 is mostly an invalid 'integer'. If you make a new variable for an object for a player, make it (-1);
new var[MAX_PLAYERS] = (-1);
CreateObject returns the spawned object ID. The very first object will be ID 0 (everything begins with '0' with counting instead of '1' in script languages).
So when the var is '-1' is means that it's "invalid", so "not spawned".

And about PVars: It's almost the same as normal variables.
Examples:

pawn Код:
new Nothing[MAX_PLAYERS];
Nothing[playerid] = 1;
is the same as
pawn Код:
SetPVarInt(playerid, "Nothing", 1);
With PVar's you don't need to define variables first. PVar's can also hold bigger strings. But they are not faster!
More examples:

pawn Код:
new Float:PosX[MAX_PLAYERS];
PosX[playerid] = 0.0;
is the same as
pawn Код:
SetPVarFloat(playerid, "PosX", 0.0);
And

pawn Код:
new PlayerText[MAX_PLAYERS][50];
strins(PlayerText[playerid], "I am Kwarde!", 0, strlen("I am Kwarde!"));
Is the same as
pawn Код:
SetPVarString(playerid, "PlayerText", "I am Kwarde!");
You can check it with the following functions.

Integer:
GetPVarInt(playerid, {var});

Float:
GetPVarFloat(playerid, {var});

String:
GetPVarString(playerid, {var});]

Example of getting the "Nothing" of the playerid...
The normal one:
pawn Код:
if(Nothing[playerid] == 1) print("OK");
The PVar
pawn Код:
if(GetPVarInt(playerid, "Nothin") == 1) print("OK");
It ain't hard
You can also remove PVars, with normal strings you can't (as far as I know)

DeletePVar(playerid, {var});
So, to remove the "Nothing":
pawn Код:
DeletePVar(playerid, "Nothing");
- Kevin
Reply


Messages In This Thread
Create- and DestroyObject. - by Ihsan-Cingisiz - 28.01.2011, 18:07
Re: Create- and DestroyObject. - by Kwarde - 28.01.2011, 18:10
Re: Create- and DestroyObject. - by Backwardsman97 - 28.01.2011, 18:15
Re: Create- and DestroyObject. - by Ihsan-Cingisiz - 28.01.2011, 20:38
Re: Create- and DestroyObject. - by Ihsan-Cingisiz - 28.01.2011, 20:45
Re: Create- and DestroyObject. - by Kasis - 28.01.2011, 20:49
Re: Create- and DestroyObject. - by Kwarde - 29.01.2011, 07:45
Re: Create- and DestroyObject. - by Ihsan-Cingisiz - 29.01.2011, 08:17

Forum Jump:


Users browsing this thread: 1 Guest(s)