29.01.2011, 07:45
Quote:
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? |
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;
pawn Код:
SetPVarInt(playerid, "Nothing", 1);
More examples:
pawn Код:
new Float:PosX[MAX_PLAYERS];
PosX[playerid] = 0.0;
pawn Код:
SetPVarFloat(playerid, "PosX", 0.0);
pawn Код:
new PlayerText[MAX_PLAYERS][50];
strins(PlayerText[playerid], "I am Kwarde!", 0, strlen("I am Kwarde!"));
pawn Код:
SetPVarString(playerid, "PlayerText", "I am Kwarde!");
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");
pawn Код:
if(GetPVarInt(playerid, "Nothin") == 1) print("OK");
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");