22.12.2016, 13:12
Goin' straight to the point
PHP код:
new ObjectID[100][2];
CMD:pickupgun(playerid, params[])
{
new f = 100+1;
for(new a = 0; a < sizeof(ObjCoords); a++) {
if(IsPlayerInRangeOfPoint(playerid, 5.0, ObjCoords[a][0], ObjCoords[a][1], ObjCoords[a][2])) {
f = a;
break;
}
}
if(f > 100) return SendClientMessage(playerid, COLOR_GREY, "You are not near the weapon which you can pick up!");
if(GetPlayerState(playerid) != 1) return SendClientMessage(playerid, COLOR_GREY, " You must be on foot !");
if(GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK) return SendClientMessage(playerid, COLOR_GREY, " You must be crouched to pick a gun.");
else {
new gunname[25], string[128];
new buffer[100];
ObjCoords[f][0] = 0.0;
ObjCoords[f][1] = 0.0;
ObjCoords[f][2] = 0.0;
DestroyDynamicObject(object[f]);
GivePlayerWeapon(playerid, ObjectID[f][0]); //ERRORLINE
GetWeaponName(ObjectID[f][0], gunname, sizeof(gunname));
format(buffer, sizeof(buffer), "You picked up a %s", gunname);
SendClientMessage(playerid, 0x33AA3300, buffer);
format(string, sizeof(string), "* %s has picked up a %s.", PlayerName(playerid), gunname);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
return 1;
}
CMD:dropgun(playerid, params[])
{
if(IsPlayerInAnyVehicle(playerid)) {
SendClientMessage (playerid, COLOR_GRAD2, "You can not drop weapons in a vehicle!");
return 1;
}
new gunid = GetPlayerWeapon(playerid);
if(gunid) {
new f = 100+1;
for(new a = 0; a < sizeof(ObjCoords); a++) {
if(ObjCoords[a][0] == 0.0) {
f = a;
break;
}
}
if(f > 100) return SendClientMessage(playerid, COLOR_GREY, "You can not throw weapons at the moment!");
new WeaponName[65];
new string[128];
GetWeaponName(gunid, WeaponName, 64);
if(gunid == 18) { WeaponName = "Molotovs"; }
if(gunid == 44) { WeaponName = "Nightvision Goggles"; }
if(gunid == 45) { WeaponName = "Infared Goggles"; }
RemovePlayerWeapon(playerid,gunid);
ObjectID[f][0] = gunid;
GetPlayerPos(playerid, ObjCoords[f][0], ObjCoords[f][1], ObjCoords[f][2]);
object[f] = CreateDynamicObject(GunObjects[gunid][0],ObjCoords[f][0],ObjCoords[f][1],ObjCoords[f][2]-1,93.7,120.0,120.0, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid), -1, 100.0);
SetTimerEx("DeleteGun", 500000, 0, "d", object[f]);
format(string, sizeof(string), "* %s has thrown away their %s.", PlayerName(playerid), WeaponName);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "You must have atleast 1 gun");
}
return 1;
}