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; }
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;
}
(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
GunLabel[playerid][Object] = CreateDynamic3DTextLabel("Gun", -1 ,GunLabel[playerid][Labx], GunLabel[playerid][Laby],GunLabel[playerid][Labz]-0.9, 2.5);}
enum GunData
{
Object,
//...
enum GunData
{
Text3D:Object,
//...
Okay, that wasn't in my code... but change:
pawn Код:
pawn Код:
|
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);
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);
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;
}