Retornar ID da Stock -
GuikBretas - 21.02.2014
E aн pessoal, fiz essa stock para criar ATMs no OnGameModeInit:
pawn Код:
stock AdicionarATM(id, Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz, estado)
{
for(new i = 0; i < sizeof(AtmInfo); i++)
{
if(AtmInfo[i][aCreated] == 0)
{
AtmInfo[i][aID]=id;
AtmInfo[i][aCreated]=1;
AtmInfo[i][aX]=x;
AtmInfo[i][aY]=y;
AtmInfo[i][aZ]=z;
AtmInfo[i][arX]=rx;
AtmInfo[i][arY]=ry;
AtmInfo[i][arZ]=rz;
AtmInfo[i][aEstado]=estado;
AtmInfo[i][aObject] = CreateObject(2942, x, y, z, rx, ry, rz);
Create3DTextLabel("Caixa Eletrфnico",Cor_Ildepick,x,y,z,15.0,0);
AddStaticPickup(1274, 1, x,y,z);
return 1;
}
}
return 0;
}
Isso aqui eu coloquei no OnGameModeInit:
AdicionarATM(1, -1677.9000200,430.3999900,6.8000000,0.0000000,0.000 0000,46.0000000, 0);
Daн eu gostaria de saber como faзo para retornar o ID do Caixa Eletrфnico e usar em um comando, exemplo um comando de Explodir.
Re: Retornar ID da Stock -
Input - 21.02.2014
Quer definir uma id para cada caixa correto?
Se sim, na AtmInfo adicione AtmID e atualize a stock para:
pawn Код:
stock AdicionarATM(id, Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz, estado)
{
for(new i = 0; i < sizeof(AtmInfo); i++)
{
if(AtmInfo[i][aCreated] == 0)
{
AtmInfo[i][aID]=id;
AtmInfo[i][aCreated]=1;
AtmInfo[i][aX]=x;
AtmInfo[i][aY]=y;
AtmInfo[i][aZ]=z;
AtmInfo[i][arX]=rx;
AtmInfo[i][arY]=ry;
AtmInfo[i][arZ]=rz;
AtmInfo[i][aEstado]=estado;
AtmInfo[i][AtmID]=i;
AtmInfo[i][aObject] = CreateObject(2942, x, y, z, rx, ry, rz);
Create3DTextLabel("Caixa Eletrфnico",Cor_Ildepick,x,y,z,15.0,0);
AddStaticPickup(1274, 1, x,y,z);
return 1;
}
}
return 0;
}
Re: Retornar ID da Stock -
Wellington1999 - 21.02.2014
vo te dara a luz
CMD:criaratm(playerid)
{
new idcaixa,estado;
if(sscanf(params, "i",estado))
return SendClientMessage(playerid, 0xFFFFFFFF, "Uso: /criaratm [ID ATM] [Estado]");
new Float
osx,Float
osy,Float
osz,Float:rx,Float:ry :Float:rz;
GetPlayerPos(playerid,posx,posy,posz);
idcaixa ++;
AdicionarATM(idcaixa, posx,posy,posz,rx,ry,rz, estado)
return 1;
}
Re: Retornar ID da Stock -
GuikBretas - 21.02.2014
Quote:
Originally Posted by Input
Quer definir uma id para cada caixa correto?
Se sim, na AtmInfo adicione AtmID e atualize a stock para:
pawn Код:
stock AdicionarATM(id, Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz, estado) { for(new i = 0; i < sizeof(AtmInfo); i++) { if(AtmInfo[i][aCreated] == 0) { AtmInfo[i][aID]=id; AtmInfo[i][aCreated]=1; AtmInfo[i][aX]=x; AtmInfo[i][aY]=y; AtmInfo[i][aZ]=z; AtmInfo[i][arX]=rx; AtmInfo[i][arY]=ry; AtmInfo[i][arZ]=rz; AtmInfo[i][aEstado]=estado; AtmInfo[i][AtmID]=i; AtmInfo[i][aObject] = CreateObject(2942, x, y, z, rx, ry, rz); Create3DTextLabel("Caixa Eletrфnico",Cor_Ildepick,x,y,z,15.0,0); AddStaticPickup(1274, 1, x,y,z); return 1; } } return 0; }
|
Sim, como eu faзo para pegar o ID junto com a posiзгo para usar em um comando?
Re: Retornar ID da Stock -
ForT - 21.02.2014
Se vocк for usar em um comando tipo: /roubar por exemplo, vocк pode usar isto aqui:
pawn Код:
stock GetPlayerCaixa(playerid){
for(new i = 0; i < sizeof(AtmInfo); i++){
if(AtmInfo[i][aCreated] &&
IsPlayerInRangeOfPoint(playerid, 5.0, AtmInfo[i][aX], AtmInfo[i][aY], AtmInfo[i][aZ]))
{
return AtmInfo[i][aID];
}
}
return -1;
}
Aqui ele retorna o Caixa eletronico mais perto do jogador..
Exemplo:
pawn Код:
CMD:roubar(playerid){
new caixaid = GetPlayerCaixa(playerid);
new str[34];
format(str, sizeof str, "Vocк esta robando o caixa id: %d", caixaid);
SendClientMessage(playerid, -1, str);
return 1;
}
Re: Retornar ID da Stock -
GuikBretas - 21.02.2014
Quote:
Originally Posted by ForT
Se vocк for usar em um comando tipo: /roubar por exemplo, vocк pode usar isto aqui:
pawn Код:
stock GetPlayerCaixa(playerid){ for(new i = 0; i < sizeof(AtmInfo); i++){ if(AtmInfo[i][aCreated] && IsPlayerInRangeOfPoint(playerid, 5.0, AtmInfo[i][aX], AtmInfo[i][aY], AtmInfo[i][aZ])) { return AtmInfo[i][aID]; } } return -1; }
Aqui ele retorna o Caixa eletronico mais perto do jogador..
Exemplo:
pawn Код:
CMD:roubar(playerid){
new caixaid = GetPlayerCaixa(playerid); new str[34]; format(str, sizeof str, "Vocк esta robando o caixa id: %d", caixaid); SendClientMessage(playerid, -1, str); return 1; }
|
Й isso mesmo o que eu preciso, muito obrigado.