Drop Gun when dead.
#5

all you need first, is your (working) command to call a function which drops your weapon. this could look like this (including the playerid, its the only parameter it needs yet):
Код:
forward DropGun(playerid); public DropGun(playerid){
	new gunID = GetPlayerWeapon(playerid);
	new gunAmmo = GetPlayerAmmo(playerid);
	if(gunID != 0 && gunAmmo != 0)
	{
		new f = maxobj+1;
		for(new a = 0; a < sizeof(ObjCoords); a++)
		{
			if(ObjCoords[a][0] == 0.0) f = a;
		}
		if(f == maxobj+1) return SendClientMessage(playerid, 0x33AA3300, "You can not throw weapons at the moment, try back later!!");
		else
		{
			new gunname[100];
			new buffer[512];
			GetWeaponNameEx(gunID, gunname, sizeof(gunname));
			format(buffer, sizeof(buffer), "You threw %s", gunname);
			SendClientMessage(playerid, 0x33AA3300, buffer);
			RemovePlayerWeapon(playerid, gunID);
			ObjectID[f][0] = gunID;
			ObjectID[f][1] = gunAmmo;
			GetPlayerPos(playerid, ObjCoords[f][0], ObjCoords[f][1], ObjCoords[f][2]);
			object[f] = CreateObject(GunObjects[gunID][0],ObjCoords[f][0],ObjCoords[f][1],ObjCoords[f][2]-1,93.7,120.0,120.0);
		}
	}
	return 1;
}
its the exact same like your command. now you need get this function be called when you type your command. so lets remove all that and just modify your onplayercommand a bit:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	new cmd[256];
	new idx;
	cmd = strtok(cmdtext, idx);
	if(strcmp(cmd, "/dropgun", true) == 0 || strcmp(cmd, "/dropwep", true) == 0)
	{
		DropGun(playerid);
	}
the DropGun(playerid); callback
replaced your command.
what changed? NOTHING. but you may use this in your OnPlayerDeath() aswell:
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	DropGun(playerid);
	return 1;
}
either you add a loop for all weapon slots (calls this callback 12 times then), this will need a second parameter, so its not worth it, or copy and modify this callback to contain this loop, dropping each weapon...
lets see what happens next ^^
Reply


Messages In This Thread
Drop Gun when dead. - by Karl1195 - 16.12.2010, 12:49
Re: Drop Gun when dead. - by Mehtab - 16.12.2010, 12:51
Re: Drop Gun when dead. - by Babul - 16.12.2010, 12:57
Re: Drop Gun when dead. - by Karl1195 - 16.12.2010, 13:00
Re: Drop Gun when dead. - by Babul - 16.12.2010, 13:36
Re: Drop Gun when dead. - by Karl1195 - 16.12.2010, 15:13
Re: Drop Gun when dead. - by Karl1195 - 16.12.2010, 15:23
Re: Drop Gun when dead. - by Babul - 16.12.2010, 19:28
Re: Drop Gun when dead. - by Karl1195 - 16.12.2010, 19:47

Forum Jump:


Users browsing this thread: 3 Guest(s)