PDA

View Full Version : Gun "droping" system problems


Supermaxultraswag
22/03/2015, 10:51 AM
new Shotgundrop[MAX_PLAYERS];
new Float: shotgunx, Float: shotgunz, Float: shotguny;

CMD:dropgun(playerid, params[])
{

GetPlayerPos(playerid, shotgunx, shotguny,shotgunz);
Shotgundrop[playerid] = CreateDynamicObject(2034,shotgunx, shotguny,shotgunz-0.9, 0, 0, 0.00);

return 1;
}

CMD:pick(playerid, params[])
{

if(IsValidDynamicObject(Shotgundrop[playerid]) && IsPlayerInRangeOfPoint(playerid,2.0,shotgunx, shotguny,shotgunz))
{
DestroyDynamicObject(Shotgundrop[playerid]);
}

return 1;
}

this system has 2 problem...
1 st problem : If I use dropgun cmd and then other player use it, my coordinates wouldn't be effective anymore, because, second player changed it... How do I save object coordinates into different variable for each player?

2 st problem : If I try cmd pick on other player object it would check If my object exist, not that player, right? (not tested it yet) If so, how do I fix that?

Threshold
22/03/2015, 11:23 AM
enum GunData
{
Object, //Stores the object ID of the weapon
Float:GunX, //Stores the X coordinate of the weapon
Float:GunY, //Stores the Y coordinate of the weapon
Float:GunZ //Stores the Z coordinate of the weapon
};
new Shotgundrop[MAX_PLAYERS][GunData]; //Used to access the 'GunData' array with respect to 'playerid'.

CMD:dropgun(playerid, params[])
{
if(IsValidDynamicObject(Shotgundrop[playerid][Object])) return SendClientMessage(playerid, -1, "You have already dropped a gun."); //If they have already used /dropgun
GetPlayerPos(playerid, Shotgundrop[playerid][GunX], Shotgundrop[playerid][GunY],Shotgundrop[playerid][GunZ]);
Shotgundrop[playerid][Object] = CreateDynamicObject(2034, Shotgundrop[playerid][GunX], Shotgundrop[playerid][GunY],Shotgundrop[playerid][GunZ] - 0.9, 0, 0, 0.00);
return 1;
}

CMD:pick(playerid, params[])
{
for(new i = 0; i < MAX_PLAYERS; i++) //Foreach is a better alternative
{
if(!IsPlayerConnected(i)) continue; //Remove if using Foreach.
if(!IsValidDynamicObject(Shotgundrop[i][Object])) continue;
if(!IsPlayerInRangeOfPoint(playerid, 2.0, Shotgundrop[i][GunX], Shotgundrop[i][GunY], Shotgundrop[i][GunZ])) continue;
DestroyDynamicObject(Shotgundrop[i][Object]);
Shotgundrop[i][Object] = -1;
return 1;
}
SendClientMessage(playerid, -1, "There are no guns nearby."); //If there are no guns within 2.0 units of the player
return 1;
}

References:
http://wiki.sa-mp.com/wiki/Scripting_Basics#Arrays
http://wiki.sa-mp.com/wiki/Keywords:Statements#for

Supermaxultraswag
23/03/2015, 01:05 PM
(1817) : warning 213: tag mismatch
(1821) : warning 215: expression has no effect
(1821) : error 001: expected token: ";", but found "["
(1821) : error 029: invalid expression, assumed zero
(1821) : warning 215: expression has no effect
(1821) : error 001: expected token: ";", but found "]"
(1821) : fatal error 107: too many error messages on one line

1821 Line:

GunLabel[playerid][Object] = CreateDynamic3DTextLabel("Gun", -1 ,GunLabel[playerid][Labx], GunLabel[playerid][Laby],GunLabel[playerid][Labz]-0.9, 2.5);}

Threshold
23/03/2015, 01:18 PM
Okay, that wasn't in my code... but change:
enum GunData
{
Object,
//...

to:
enum GunData
{
Text3D:Object,
//...

EDIT: And is that closing brace "}" meant to be at the end of that line?

Supermaxultraswag
23/03/2015, 04:27 PM
Okay, that wasn't in my code... but change:
enum GunData
{
Object,
//...

to:
enum GunData
{
Text3D:Object,
//...

EDIT: And is that closing brace "}" meant to be at the end of that line?

Yes it wasn't, I tried to add some stuff to system. "}" meant to be there, and it still gives me these errors even after I add "Text3D"

Guess it will be better If I give you full code

enum GunData{
Gun,
Text3D: Object,
Float:Labx,
Float:Laby,
Float:Labz
};
new GunDrop[MAX_PLAYERS][GunData], GunLabel[MAX_PLAYERS][GunData];

GetPlayerPos(playerid, GunLabel[playerid][Labx], GunLabel[playerid][Laby],GunLabel[playerid][Labz]);
GunDrop[playerid][Gun] = CreateDynamicObject(356, GunLabel[playerid][Labx], GunLabel[playerid][Laby],GunLabel[playerid][Labz]-0.9, 0, 0, 0.00);
GunLabel[playerid][Object] = CreateDynamic3DTextLabel("Gun", -1 ,GunLabel[playerid][Labx], GunLabel[playerid][Laby],GunLabel[playerid][Labz]-0.9, 2.5);

Threshold
24/03/2015, 03:24 AM
This works for me:
enum GunData{
Gun,
Text3D:Object,
Float:Labx,
Float:Laby,
Float:Labz
};
new GunDrop[MAX_PLAYERS][GunData];

GetPlayerPos(playerid, GunDrop[playerid][Labx], GunDrop[playerid][Laby], GunDrop[playerid][Labz]);
GunDrop[playerid][Gun] = CreateDynamicObject(356, GunDrop[playerid][Labx], GunDrop[playerid][Laby], GunDrop[playerid][Labz] - 0.9, 0, 0, 0.00);
GunDrop[playerid][Object] = CreateDynamic3DTextLabel("Gun", -1, GunDrop[playerid][Labx], GunDrop[playerid][Laby], GunDrop[playerid][Labz] - 0.9, 2.5);

Supermaxultraswag
24/03/2015, 04:04 PM
Ok, I fixed it all. Thank you for the help mate.

Supermaxultraswag
27/03/2015, 09:05 PM
Bruh your system doesnt work too. Player still can't take other player "droped" gun

Supermaxultraswag
28/03/2015, 10:16 AM
Bump

Threshold
28/03/2015, 12:54 PM
Well, there's nothing wrong with my code. You must have changed something.

EDIT:
CMD:pick(playerid, params[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
if(IsValidDynamicObject(Gundrop[i][GunObject]))
{
if(IsPlayerInRangeOfPoint(i, 2.0, Gundrop[i][Gunx], Gundrop[i][Guny], Gundrop[i][Gunz]))
{
DestroyDynamicObject(Gundrop[i][GunObject]);
DestroyDynamic3DTextLabel(Gundroplabel[i][GunLabel]);
}
}
else if(IsValidDynamicObject(Gundrop2[i][GunObject1]))
{
if(IsPlayerInRangeOfPoint(i, 2.0, Gundrop2[i][Gun1x], Gundrop2[i][Gun1y], Gundrop2[i][Gun1z]))
{
DestroyDynamicObject(Gundrop2[i][GunObject1]);
DestroyDynamic3DTextLabel(Gundroplabel2[i][GunLabel1]);
}
}
}
return 1;
}

Supermaxultraswag
30/03/2015, 06:04 PM
I dont understand why my code isn't working... It seems like I did everything as you say...

Please take a look at this

https://www.youtube.com/watch?v=DR2ajcAltZM&feature=youtu.be (sorry for the song, i was listening to some playlist while recording)

If I drop both of objects first I have to take object who was dropped before second... otherwise i can't take second object. Srsly dafuq

enum GunData{
GunObject,
Text3D: GunLabel,
Float:gunx,
Float:guny,
Float:gunz};

enum GunData1{
GunObject1,
Text3D: GunLabel1,
Float:gun1x,
Float:gun1y,
Float:gun1z
};
new Gun[MAX_PLAYERS][GunData],Gun2[MAX_PLAYERS][GunData1];
new Text3D:Gunlabel[MAX_PLAYERS][GunData],Text3D:Gunlabel2[MAX_PLAYERS][GunData1];

CMD:pick(playerid, params[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
if(IsValidDynamicObject(Gun[i][GunObject]))
{
if(IsPlayerInRangeOfPoint(i,2.0,Gun[i][gunx], Gun[i][guny],Gun[i][gunz]))
{
DestroyDynamicObject(Gun[i][GunObject]);
DestroyDynamic3DTextLabel(Gunlabel[i][GunLabel]);
}
}
else if(IsValidDynamicObject(Gun2[i][GunObject1]))
{
if(IsPlayerInRangeOfPoint(i,2.0,Gun2[i][gun1x], Gun2[i][gun1y],Gun2[i][gun1z]))
{
DestroyDynamicObject(Gun2[i][GunObject1]);
DestroyDynamic3DTextLabel(Gunlabel2[i][GunLabel1]);
}
}
}
return 1;
}

CMD:drop(playerid, params[])
{
if(!IsValidDynamicObject(Gun[playerid][GunObject]) && !IsValidDynamicObject(Gun2[playerid][GunObject1]))
{
GetPlayerPos(playerid, Gun[playerid][gunx], Gun[playerid][guny],Gun[playerid][gunz]);
Gun[playerid][GunObject] = CreateDynamicObject(349, Gun[playerid][gunx], Gun[playerid][guny],Gun[playerid][gunz]-0.9, 0, 0, 0.00);
Gunlabel[playerid][GunLabel] = CreateDynamic3DTextLabel("Gun", 0xFFFFFFAA,Gun[playerid][gunx], Gun[playerid][guny],Gun[playerid][gunz]-0.9, 2.5);
}

else if(IsValidDynamicObject(Gun[playerid][GunObject]) && !IsValidDynamicObject(Gun2[playerid][GunObject1]))
{ //// 2
GetPlayerPos(playerid, Gun2[playerid][gun1x], Gun2[playerid][gun1y],Gun2[playerid][gun1z]);
Gun2[playerid][GunObject1] = CreateDynamicObject(349, Gun2[playerid][gun1x], Gun2[playerid][gun1y],Gun2[playerid][gun1z]-0.9, 0, 0, 0.00);
Gunlabel2[playerid][GunLabel1] = CreateDynamic3DTextLabel("Gun", 0xFFFFFFAA,Gun2[playerid][gun1x], Gun2[playerid][gun1y],Gun2[playerid][gun1z]-0.9, 2.5);
}
else if(IsValidDynamicObject(Gun[playerid][GunObject]) && IsValidDynamicObject(Gun2[playerid][GunObject1]))
{ /// 3
DestroyDynamicObject(Gun[playerid][GunObject]);
DestroyDynamic3DTextLabel(Gunlabel[playerid][GunLabel]);
GetPlayerPos(playerid, Gun[playerid][gunx], Gun[playerid][guny],Gun[playerid][gunz]);
Gun[playerid][GunObject] = CreateDynamicObject(349, Gun[playerid][gunx], Gun[playerid][guny],Gun[playerid][gunz]-0.9, 0, 0, 0.00);
Gunlabel[playerid][GunLabel] = CreateDynamic3DTextLabel("Gun", 0xFFFFFFAA,Gun[playerid][gunx], Gun[playerid][guny],Gun[playerid][gunz]-0.9, 2.5);
}
return 1;
}

Threshold
30/03/2015, 08:50 PM
Try this:
CMD:pick(playerid, params[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
if(IsValidDynamicObject(Gun[i][GunObject]))
{
if(IsPlayerInRangeOfPoint(i,2.0,Gun[i][gunx], Gun[i][guny],Gun[i][gunz]))
{
DestroyDynamicObject(Gun[i][GunObject]);
DestroyDynamic3DTextLabel(Gunlabel[i][GunLabel]);
break;
}
}
if(IsValidDynamicObject(Gun2[i][GunObject1]))
{
if(IsPlayerInRangeOfPoint(i,2.0,Gun2[i][gun1x], Gun2[i][gun1y],Gun2[i][gun1z]))
{
DestroyDynamicObject(Gun2[i][GunObject1]);
DestroyDynamic3DTextLabel(Gunlabel2[i][GunLabel1]);
break;
}
}
}
return 1;
}

My fault, I shouldn't have used an 'else if'.

Supermaxultraswag
31/03/2015, 03:40 PM
Try this:
CMD:pick(playerid, params[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
if(IsValidDynamicObject(Gun[i][GunObject]))
{
if(IsPlayerInRangeOfPoint(i,2.0,Gun[i][gunx], Gun[i][guny],Gun[i][gunz]))
{
DestroyDynamicObject(Gun[i][GunObject]);
DestroyDynamic3DTextLabel(Gunlabel[i][GunLabel]);
break;
}
}
if(IsValidDynamicObject(Gun2[i][GunObject1]))
{
if(IsPlayerInRangeOfPoint(i,2.0,Gun2[i][gun1x], Gun2[i][gun1y],Gun2[i][gun1z]))
{
DestroyDynamicObject(Gun2[i][GunObject1]);
DestroyDynamic3DTextLabel(Gunlabel2[i][GunLabel1]);
break;
}
}
}
return 1;
}

My fault, I shouldn't have used an 'else if'.

Ok, I can take both objects now, but... I still can't take other player object. Here's video :

https://www.youtube.com/watch?v=1PaGsAvB2x8&feature=youtu.be

Threshold
01/04/2015, 05:06 AM
Sorry, I didn't look at the full code in your last post. I will fix it when I get home and send you a forum PM.

Supermaxultraswag
01/04/2015, 06:27 AM
Sorry, I didn't look at the full code in your last post. I will fix it when I get home and send you a forum PM.

Thank you, I'll wait.

Threshold
01/04/2015, 09:43 AM
This should do:
enum GunData
{
GunObject,
Text3D:GunLabel,
Float:gunx,
Float:guny,
Float:gunz
};

new Gun[MAX_PLAYERS][2][GunData];

CMD:pick(playerid, params[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
if(IsValidDynamicObject(Gun[i][0][GunObject]))
{
if(IsPlayerInRangeOfPoint(i, 2.0, Gun[i][0][gunx], Gun[i][0][guny], Gun[i][0][gunz]))
{
DestroyDynamicObject(Gun[i][0][GunObject]);
DestroyDynamic3DTextLabel(Gun[i][0][GunLabel]);
break;
}
}
if(IsValidDynamicObject(Gun[i][1][GunObject]))
{
if(IsPlayerInRangeOfPoint(i, 2.0, Gun[i][1][gunx], Gun[i][1][guny], Gun[i][1][gunz]))
{
DestroyDynamicObject(Gun[i][1][GunObject]);
DestroyDynamic3DTextLabel(Gun[i][1][GunLabel]);
break;
}
}
}
return 1;
}

CMD:drop(playerid, params[])
{
new gunid = -1;
if(!IsValidDynamicObject(Gun[playerid][0][GunObject])) gunid = 0;
else if(!IsValidDynamicObject(Gun[playerid][1][GunObject])) gunid = 1;
else return SendClientMessage(playerid, -1, "You have already dropped 2 guns.");

GetPlayerPos(playerid, Gun[playerid][gunid][gunx], Gun[playerid][gunid][guny], Gun[playerid][gunid][gunz]);
Gun[playerid][gunid][GunObject] = CreateDynamicObject(349, Gun[playerid][gunid][gunx], Gun[playerid][gunid][guny], Gun[playerid][gunid][gunz] - 0.9, 0, 0, 0.00);
Gun[playerid][gunid][GunLabel] = CreateDynamic3DTextLabel("Gun", 0xFFFFFFAA, Gun[playerid][gunid][gunx], Gun[playerid][gunid][guny], Gun[playerid][gunid][gunz] - 0.9, 2.5);
return 1;
}

'Gun[playerid][0]' is for the first gun. 'Gun[playerid][1]' is for the second gun.

Supermaxultraswag
01/04/2015, 05:04 PM
This should do:
enum GunData
{
GunObject,
Text3D:GunLabel,
Float:gunx,
Float:guny,
Float:gunz
};

new Gun[MAX_PLAYERS][2][GunData];

CMD:pick(playerid, params[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
if(IsValidDynamicObject(Gun[i][0][GunObject]))
{
if(IsPlayerInRangeOfPoint(i, 2.0, Gun[i][0][gunx], Gun[i][0][guny], Gun[i][0][gunz]))
{
DestroyDynamicObject(Gun[i][0][GunObject]);
DestroyDynamic3DTextLabel(Gun[i][0][GunLabel]);
break;
}
}
if(IsValidDynamicObject(Gun[i][1][GunObject]))
{
if(IsPlayerInRangeOfPoint(i, 2.0, Gun[i][1][gunx], Gun[i][1][guny], Gun[i][1][gunz]))
{
DestroyDynamicObject(Gun[i][1][GunObject]);
DestroyDynamic3DTextLabel(Gun[i][1][GunLabel]);
break;
}
}
}
return 1;
}

CMD:drop(playerid, params[])
{
new gunid = -1;
if(!IsValidDynamicObject(Gun[playerid][0][GunObject])) gunid = 0;
else if(!IsValidDynamicObject(Gun[playerid][1][GunObject])) gunid = 1;
else return SendClientMessage(playerid, -1, "You have already dropped 2 guns.");

GetPlayerPos(playerid, Gun[playerid][gunid][gunx], Gun[playerid][gunid][guny], Gun[playerid][gunid][gunz]);
Gun[playerid][gunid][GunObject] = CreateDynamicObject(349, Gun[playerid][gunid][gunx], Gun[playerid][gunid][guny], Gun[playerid][gunid][gunz] - 0.9, 0, 0, 0.00);
Gun[playerid][gunid][GunLabel] = CreateDynamic3DTextLabel("Gun", 0xFFFFFFAA, Gun[playerid][gunid][gunx], Gun[playerid][gunid][guny], Gun[playerid][gunid][gunz] - 0.9, 2.5);
return 1;
}

'Gun[playerid][0]' is for the first gun. 'Gun[playerid][1]' is for the second gun.

Umm, don't know why, but other player can take my object only if I'm near that object.
For example I'm 20 steps away from my object. Other player can't take it.
But If I'm near object (in 2.5 range) other player can take it. If you need, I can make video.

As I understand, problem is somewhere here...

if(IsPlayerInRangeOfPoint(i, 2.0, Gun[i][0][gunx], Gun[i][0][guny], Gun[i][0][gunz]))

But I can't find what's wrong.

Threshold
01/04/2015, 10:50 PM
Urgh I don't know why I keep making these mistakes. I didn't get home until late so I had to write that code on my phone. In the IsPlayerInRangeOfPoint lines, change the 'i' to 'playerid'.

Eg.
if(IsPlayerInRangeOfPoint(playerid, 2.0, Gun[i][0][gunx], Gun[i][0][guny], Gun[i][0][gunz]))

Do the same for the other line.

PowerPC603
02/04/2015, 04:58 AM
Since you drop the gun into the global world, and other players need to be able to pick it up, it's no longer related to one player specifically.
Yet, all posted code still uses the playerid for accessing the arrays.

Just use a global array which holds all dropped guns with no relation to a player.

When you drop a gun, loop through the array to find an empty index and add your dropped gun there.
When another player wants to pick it up, loop through the same array and if he's in range of the gun, allow him to pick it up.


enum DroppedGun
{
Object,
Float:PosX,
Float:PosY,
Float:PosZ,
playername[24]
}
new DroppedGuns[500][DroppedGun];



CMD:drop(playerid, params[])
{
new Float:x, Float:y, Float:z, name[24];

GetPlayerPos(playerid, x, y, z);
GetPlayerName(playerid, name, sizeof(name));

// Loop through the array to find an empty index where no object exists
for (new i; i < sizeof(DroppedGuns); i++)
{
// Check if this index is empty (no object present)
if (!IsValidDynamicObject(DroppedGuns[i][Object])
{
// Create the object and store data
DroppedGuns[i][Object] = CreateDynamicObject(349, x, y, z, 0, 0, 0.00);
DroppedGuns[i][PosX] = x;
DroppedGuns[i][PosY] = y;
DroppedGuns[i][PosZ] = z;
format(DroppedGuns[i][playername], 24, name);
// Inform the player
SendClientMessage(playerid, -1, "You've dropped the gun");
// Exit the loop
break;
}
}

return 1;
}

CMD:pick(playerid, params[])
{
new Msg[128];

// Loop through the array
for(new i; i < sizeof(DroppedGuns); i++)
{
// Check if this index is occupied (a dropped gun exists)
if(IsValidDynamicObject(DroppedGuns[i][Object]))
{
// Check if the player is near this dropped gun
if(IsPlayerInRangeOfPoint(playerid, 2.5, DroppedGuns[i][PosX], DroppedGuns[i][PosY], DroppedGuns[i][PosZ]))
{
// Destroy the object as it has been picked up
DestroyDynamicObject(DroppedGuns[i][Object]);
// Inform the player
format(Msg, sizeof(Msg), "You've picked up a gun dropped by %s", DroppedGuns[i][playername]);
SendClientMessage(playerid, -1, Msg);
// Exit the loop
break;
}
}
}

return 1;
}

This should work for all players.
Adapt object-id's if needed and add other code like removing the currently held weapon from the player upon dropping it or giving a new weapon to the player who picks it up or whatever you need to do with it.

You could also add different modelid's for the object depending on which weapon the player drops using a switch-case structure, and also detect the modelid when you pick it up again and give the appropriate weapon back.

Supermaxultraswag
02/04/2015, 04:01 PM
Urgh I don't know why I keep making these mistakes. I didn't get home until late so I had to write that code on my phone. In the IsPlayerInRangeOfPoint lines, change the 'i' to 'playerid'.

Eg.
if(IsPlayerInRangeOfPoint(playerid, 2.0, Gun[i][0][gunx], Gun[i][0][guny], Gun[i][0][gunz]))

Do the same for the other line.


Urgh I don't know why I keep making these mistakes. I didn't get home until late so I had to write that code on my phone. In the IsPlayerInRangeOfPoint lines, change the 'i' to 'playerid'.

Eg.
if(IsPlayerInRangeOfPoint(playerid, 2.0, Gun[i][0][gunx], Gun[i][0][guny], Gun[i][0][gunz]))

Do the same for the other line.

Since you drop the gun into the global world, and other players need to be able to pick it up, it's no longer related to one player specifically.
Yet, all posted code still uses the playerid for accessing the arrays.

Just use a global array which holds all dropped guns with no relation to a player.

When you drop a gun, loop through the array to find an empty index and add your dropped gun there.
When another player wants to pick it up, loop through the same array and if he's in range of the gun, allow him to pick it up.


enum DroppedGun
{
Object,
Float:PosX,
Float:PosY,
Float:PosZ,
playername[24]
}
new DroppedGuns[500][DroppedGun];



CMD:drop(playerid, params[])
{
new Float:x, Float:y, Float:z, name[24];

GetPlayerPos(playerid, x, y, z);
GetPlayerName(playerid, name, sizeof(name));

// Loop through the array to find an empty index where no object exists
for (new i; i < sizeof(DroppedGuns); i++)
{
// Check if this index is empty (no object present)
if (!IsValidDynamicObject(DroppedGuns[i][Object])
{
// Create the object and store data
DroppedGuns[i][Object] = CreateDynamicObject(349, x, y, z, 0, 0, 0.00);
DroppedGuns[i][PosX] = x;
DroppedGuns[i][PosY] = y;
DroppedGuns[i][PosZ] = z;
format(DroppedGuns[i][playername], 24, name);
// Inform the player
SendClientMessage(playerid, -1, "You've dropped the gun");
// Exit the loop
break;
}
}

return 1;
}

CMD:pick(playerid, params[])
{
new Msg[128];

// Loop through the array
for(new i; i < sizeof(DroppedGuns); i++)
{
// Check if this index is occupied (a dropped gun exists)
if(IsValidDynamicObject(DroppedGuns[i][Object]))
{
// Check if the player is near this dropped gun
if(IsPlayerInRangeOfPoint(playerid, 2.5, DroppedGuns[i][PosX], DroppedGuns[i][PosY], DroppedGuns[i][PosZ]))
{
// Destroy the object as it has been picked up
DestroyDynamicObject(DroppedGuns[i][Object]);
// Inform the player
format(Msg, sizeof(Msg), "You've picked up a gun dropped by %s", DroppedGuns[i][playername]);
SendClientMessage(playerid, -1, Msg);
// Exit the loop
break;
}
}
}

return 1;
}

This should work for all players.
Adapt object-id's if needed and add other code like removing the currently held weapon from the player upon dropping it or giving a new weapon to the player who picks it up or whatever you need to do with it.

You could also add different modelid's for the object depending on which weapon the player drops using a switch-case structure, and also detect the modelid when you pick it up again and give the appropriate weapon back.

Thanks to both of you, I got system that I needed. Thank you very much!