23.10.2011, 16:17
This is some fairly rediculous code, your function could be cleaned up so much, for example:
Doesn't that make a lot more sense?
Then for another example, your pickup code is insanity, why do you loop through every single player when the ID of the player that stepped on the mine is already given to you?
For example:
Now doesn't that make a lot more sense? Instead of looping through every single player on the server (multiple times might I add), simply use the ID that is passed to you!
pawn Код:
public vdtext(playerid)
{
if(vcountpos[playerid] == 0)
{
Delete3DTextLabel(vlaber[playerid]);
vcountpos[playerid] = 0;
vminePickup[playerid] = CreatePickup(0, 14, X, Y, Z, -1);
}
else
{
vtimer[playerid] = SetTimerEx("vdtext", 1000, 0, "i", playerid);
new Float:X, Float:Y, Float:Z, str[128];
GetObjectPos(vmine[playerid][0], X, Y, Z);
vcountpos[playerid]--;
format(str, sizeof(str), "to activate the left: \n%d seconds", vcountpos[playerid]);
if(vcountpos == 10)
vlaber[playerid] = Create3DTextLabel(str, 0x00F900AA, X, Y, Z + 1, 40.0, 0);
else
Update3DTextLabelText(vlaber[playerid], 0x64F801AA, str);
}
return 1;
}
Then for another example, your pickup code is insanity, why do you loop through every single player when the ID of the player that stepped on the mine is already given to you?
For example:
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == minePickup[playerid] && status[playerid] != 0))
{
new Float:X, Float:Y, Float:Z;
GetObjectPos(mine[playerid][0], X, Y, Z);
CreateExplosion(X, Y, Z, 4, 1);
CreateExplosion(X, Y, Z, 12, 1);
DestroyPickup(minePickup[playerid]);
DestroyObject(mine[playerid][0]);
DestroyObject(mine[playerid][1]);
status[playerid] = 0;
GameTextForPlayer(playerid,"~r~You have stepped on a mine!",6000,1);
}
else if(pickupid == vminePickup[playerid] && if(vstatus[playerid] != 0))
{
new Float:X, Float:Y, Float:Z;
GetObjectPos(vmine[playerid][0], X, Y, Z);
CreateExplosion(X, Y, Z, 7, 1);
DestroyPickup(vminePickup[playerid]);
DestroyObject(vmine[playerid][0]);
vstatus[playerid] = 0;
GameTextForPlayer(playerid,"~r~You have driven over a mine!",6000,1);
}
return 1;
}