Comando de dar sua arma -
bombomloko - 16.11.2013
Existe a possibilidade de um player dar as suas armas da mгo pra outro player? Ex.: Fulaninho tem uma Eagle com 490 muniзгo e quer dar ela pro Beelzebub, ai ele usa /dar arma iddobeelzebub e o Beelzebub recebe a eagle com 490 de muniзгo (Fulaninho perde a arma da mгo, уbvio). Tem como fazer isso?
Respuesta: Comando de dar sua arma -
ViniKuliveguisky - 16.11.2013
Claro que tem!
Vo fazer aqui e ja te mostro um exemplo!
pawn Код:
CMD:dararma(playerid, params[])
{
new giveplayerid;
if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, COLOR_WHITE, "[INFO] /dararma [id]");
new arma = GetPlayerWeapon(playerid);
new muni = GetPlayerAmmo(playerid);
GivePlayerWeapon(giveplayerid, arma, muni);
new msg[70], player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME];
GetPlayerName(playerid, player, sizeof(player));
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
format(msg, sizeof(msg), "Vocк deu uma arma para %s com %i de muniзгo!", giveplayer, muni);
SendClientMessage(playerid, COLOR_LIGHTBLUE, msg);
format(msg, sizeof(msg), "Vocк recebeu uma arma de %s com %i de muniзгo!", player, muni);
SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, msg);
RemovePlayerWeapon(giveplayerid, arma);
return 1;
}
e adiciona isso no fim do GM
pawn Код:
stock RemovePlayerWeapon(playerid, weaponid)
{
new pWeaponData[13][2];
for (new i = 0; i < 13; i++)
{
GetPlayerWeaponData(playerid, i, pWeaponData[i][0], pWeaponData[i][1]);
}
ResetPlayerWeapons(playerid);
for(new i=0; i<13; i++)
{
if(pWeaponData[i][0] != 0 && pWeaponData[i][0] != weaponid)
{
GivePlayerWeapon(playerid, pWeaponData[i][0], pWeaponData[i][1]);
}
}
return 0;
}
Re: Comando de dar sua arma -
SeV_ - 16.11.2013
https://sampwiki.blast.hk/wiki/GetPlayerWeaponData
https://sampwiki.blast.hk/wiki/GivePlayerWeapon
Re: Respuesta: Comando de dar sua arma -
bombomloko - 16.11.2013
Quote:
Originally Posted by ViniKuliveguisky
Claro que tem!
Vo fazer aqui e ja te mostro um exemplo!
pawn Код:
CMD:dararma(playerid, params[]) { new giveplayerid; if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, COLOR_WHITE, "[INFO] /dararma [id]"); new arma = GetPlayerWeapon(playerid); new muni = GetPlayerAmmo(playerid); GivePlayerWeapon(giveplayerid, arma, muni); new msg[70], player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME]; GetPlayerName(playerid, player, sizeof(player)); GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer)); format(msg, sizeof(msg), "Vocк deu uma arma para %s com %i de muniзгo!", giveplayer, muni); SendClientMessage(playerid, COLOR_LIGHTBLUE, msg); format(msg, sizeof(msg), "Vocк recebeu uma arma de %s com %i de muniзгo!", player, muni); SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, msg); RemovePlayerWeapon(giveplayerid, arma); return 1; }
e adiciona isso no fim do GM
pawn Код:
stock RemovePlayerWeapon(playerid, weaponid) { new pWeaponData[13][2]; for (new i = 0; i < 13; i++) { GetPlayerWeaponData(playerid, i, pWeaponData[i][0], pWeaponData[i][1]); }
ResetPlayerWeapons(playerid); for(new i=0; i<13; i++) { if(pWeaponData[i][0] != 0 && pWeaponData[i][0] != weaponid) { GivePlayerWeapon(playerid, pWeaponData[i][0], pWeaponData[i][1]); } } return 0; }
|
tб dando a arma pro player mas nгo ta removendo a arma de quem deu
Respuesta: Re: Respuesta: Comando de dar sua arma -
ViniKuliveguisky - 16.11.2013
Quote:
Originally Posted by bombomloko
tб dando a arma pro player mas nгo ta removendo a arma de quem deu
|
Ops coloquei errado!
troca essa linha
pawn Код:
RemovePlayerWeapon(giveplayerid, arma);
Por:
pawn Код:
RemovePlayerWeapon(playerid, arma);
Re: Comando de dar sua arma -
zPain - 16.11.2013
Desenvolvi um cуdigo pra vocк, que compilou perfeitamente. Quanto ao funcionamento, cabe a vocк testar.
pawn Код:
CMD:dararmas(playerid, params[]) {
new targetid;
if(sscanf(params, "u", targetid)) {
return SendClientMessage(playerid, -1, "Uso: /dararmas <id>");
}
if(!IsPlayerConnected(targetid)) {
return SendClientMessage(playerid, -1, "Jogador offline.");
}
if(!getWeapons(playerid)) {
return SendClientMessage(playerid, -1, "Vocк estб desarmado.");
}
new x, w, a;
for(x = 0; x < 13; ++x) {
GetPlayerWeaponData(playerid, x, w, a);
if(w) {
GivePlayerWeapon(targetid, w, a);
}
}
new string[120];
GetPlayerName(playerid, string, 25);
format(string, sizeof string, "%s deu as armas dele pra vocк.", string);
SendClientMessage(targetid, -1, string);
GetPlayerName(targetid, string, 25);
format(string, sizeof string, "Vocк deu suas armas para %s.", string);
SendClientMessage(playerid, -1, string);
ResetPlayerWeapons(playerid);
return true;
}
getWeapons(playerid) {
new total = 0,
x, w, a;
for(x = 12; x > -1; --x) {
GetPlayerWeaponData(playerid, x, w, a);
if(x) {
++total;
}
}
return total;
}
Re: Respuesta: Re: Respuesta: Comando de dar sua arma -
bombomloko - 17.11.2013
Quote:
Originally Posted by ViniKuliveguisky
Ops coloquei errado!
troca essa linha
pawn Код:
RemovePlayerWeapon(giveplayerid, arma);
Por:
pawn Код:
RemovePlayerWeapon(playerid, arma);
|
no cуdigo que vocк me passou nгo tem nenhuma linha de RemovePlayerWeapon
Quote:
Originally Posted by zPain
Desenvolvi um cуdigo pra vocк, que compilou perfeitamente. Quanto ao funcionamento, cabe a vocк testar.
pawn Код:
CMD:dararmas(playerid, params[]) {
new targetid; if(sscanf(params, "u", targetid)) { return SendClientMessage(playerid, -1, "Uso: /dararmas <id>"); }
if(!IsPlayerConnected(targetid)) { return SendClientMessage(playerid, -1, "Jogador offline."); }
if(!getWeapons(playerid)) { return SendClientMessage(playerid, -1, "Vocк estб desarmado."); }
new x, w, a; for(x = 0; x < 13; ++x) { GetPlayerWeaponData(playerid, x, w, a);
if(w) { GivePlayerWeapon(targetid, w, a); } }
new string[120];
GetPlayerName(playerid, string, 25); format(string, sizeof string, "%s deu as armas dele pra vocк.", string); SendClientMessage(targetid, -1, string);
GetPlayerName(targetid, string, 25); format(string, sizeof string, "Vocк deu suas armas para %s.", string); SendClientMessage(playerid, -1, string);
ResetPlayerWeapons(playerid); return true; }
getWeapons(playerid) {
new total = 0, x, w, a;
for(x = 12; x > -1; --x) { GetPlayerWeaponData(playerid, x, w, a);
if(x) { ++total; } } return total; }
|
nгo й isso que eu quero, pelo comando que vocк fez, percebi que ele da TODAS armas da mгo pro player, eu quero que desse apenas a selecionada, que ele estб segurando no momento que for usar o comando.
a propуsito, eu uso strcmp, entгo se vocкs pudessem me ajudar em strcmp, seria melhor...