CMD:pickup(playerid, params[])
{
for(new i = 0; i < MAX_LABELS; i++)
{
if(IsPlayerInRangeOfPoint(playerid, 3.0, LabelInfo[i][LabelX], LabelInfo[i][LabelY], LabelInfo[i][LabelZ]))
{
format(GlobalString, sizeof(GlobalString), "%s picks up a weapon shell from the ground.", GetUsername(playerid));
ProxDetector(15.0, playerid, GlobalString, COLOR_PURPLE);
Delete3DTextLabel(Text3D:LabelInfo[i][LabelID]);
break;
}
else SendClientMessage(playerid, COLOR_RED, "Error:"COL_WHITE" You're not near anything to pickup."); break;
}
return true;
}
enum DLabel
{
LabelID,
LabelName[60],
Float:LabelX,
Float:LabelY,
Float:LabelZ,
LabelInt,
LabelVW,
LabelOwner[24],
Pickup,
Holding[24],
}
new LabelInfo[MAX_LABELS][DLabel];
CMD:pickup(playerid, params[])
{
new bool:inrange;
for(new i = 0; i < MAX_LABELS; i++)
{
if(IsPlayerInRangeOfPoint(playerid, 3.0, LabelInfo[i][LabelX], LabelInfo[i][LabelY], LabelInfo[i][LabelZ]))
{
format(GlobalString, sizeof(GlobalString), "%s picks up a weapon shell from the ground.", GetUsername(playerid));
ProxDetector(15.0, playerid, GlobalString, COLOR_PURPLE);
Delete3DTextLabel(Text3D:LabelInfo[i][LabelID]);
inrange = true;
break;
}
}
if (!inrange) SendClientMessage(playerid, COLOR_RED, "Error:"COL_WHITE" You're not near anything to pickup.");
return true;
}
Don't send the message that you're not in range in a loop because if you're not in range for the first item but you are for an item, it will send the message and stop.
PHP код:
|
enum DLabel
{
Text3D:LabelID,
LabelName[60],
Float:LabelX,
Float:LabelY,
Float:LabelZ,
LabelInt,
LabelVW,
LabelOwner[24],
Pickup,
Holding[24],
}
new LabelInfo[MAX_LABELS][DLabel];
CMD:pickup(playerid, params[])
{
for(new i = 0; i < MAX_LABELS; i++)
{
if(IsPlayerInRangeOfPoint(playerid, 3.0, LabelInfo[i][LabelX], LabelInfo[i][LabelY], LabelInfo[i][LabelZ]))
{
format(GlobalString, sizeof(GlobalString), "%s picks up a weapon shell from the ground.", GetUsername(playerid));
ProxDetector(15.0, playerid, GlobalString, COLOR_PURPLE);
Delete3DTextLabel(LabelInfo[i][LabelID]);
return 1;
}
else SendClientMessage(playerid, COLOR_RED, "Error:"COL_WHITE" You're not near anything to pickup.");
}
return 1;
}
CMD:pickup(playerid, params[])
{
new bool:inrange;
for(new i = 0; i < MAX_LABELS; i++)
{
if(IsPlayerInRangeOfPoint(playerid, 3.0, LabelInfo[i][LabelX], LabelInfo[i][LabelY], LabelInfo[i][LabelZ]))
{
format(GlobalString, sizeof(GlobalString), "%s picks up a weapon shell from the ground.", GetUsername(playerid));
ProxDetector(15.0, playerid, GlobalString, COLOR_PURPLE);
DestroyDynamic3DTextLabel(Text3D:LabelInfo[i][LabelID]);
inrange = true;
break;
}
}
if (!inrange) SendClientMessage(playerid, COLOR_RED, "Error:"COL_WHITE" You're not near anything to pickup.");
return true;
}
Do you mean that it only destroys the first 3D label and not the rest? If so, post the code you create those 3D labels.
|
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
new Float:pX, Float:pY, Float:pZ;
GetPlayerPos(playerid, Float:pX, Float:pY, Float:pZ);
CreateLabel(""COL_RED"["COL_WHITE"Weapon Shell"COL_RED"]", pX, pY, pZ, GetPlayerInterior(playerid), GetPlayerVirtualWorld(playerid), GetUsername(playerid));
return 1;
}
CreateLabel(LName[60], Float:LX, Float:LY, Float:LZ, LInt, LVW, LOwner[24])
{
format(GlobalQuery, sizeof(GlobalQuery), "INSERT INTO `labels` (LabelName, LabelX, LabelY, LabelZ, LabelInt, LabelVW, LabelOwner) VALUES ('%s', %f, %f, %f, %d, %d, '%s')", LName, Float:LX, Float:LY, Float:LZ, LInt, LVW, LOwner);
mysql_function_query(MySQLConnection, GlobalQuery, true, "LabelCreated", "");
return true;
}