[Ajuda] Ajuda (preciso aprender isso)
#1

Galera, preciso de ajuda, eu quero criar varias pedras pelo mapa pra uma profissгo apertar Y em uma delas e remove-la. assim em todas as 4, so que eu fiz um codigo de testes que na minha teoria estaria certo, mas nгo consegui;

Код:
new pedra[4];
Код:
public OnGameModeInit()
{
	pedra[0] = CreateObject(745, 299.27261, 1423.04456, 8.71771,   0.00000, 0.00000, 0.00000);
	pedra[1] = CreateObject(745, 294.43201, 1393.79041, 9.17888,   0.00000, 0.00000, 0.00000);
	pedra[2] = CreateObject(745, 314.09689, 1410.77551, 7.35632,   0.00000, 0.00000, 0.00000);
	pedra[3] = CreateObject(745, 308.55414, 1385.33337, 8.15589,   0.00000, 0.00000, 0.00000);
	return 1;
}

Код:
new Float:Mecanicos[3][4] = {

  {pedra[0], 299.27261, 1423.04456, 8.71771},
  {pedra[1], 294.43201, 1393.79041, 9.17888},
  {pedra[2], 314.09689, 1410.77551, 7.35632},
  {pedra[3], 308.55414, 1385.33337, 8.15589}};


public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_YES)
    {
        for(new i = 0; i < sizeof(Mecanicos); i++)
        {
            if(IsPlayerInRangeOfPoint(playerid, 5.0, Mecanicos[i][1], Mecanicos[i][2], Mecanicos[i][3]))
            {
            		SendClientMessage(playerid, -1, "Vocк esta no raio de uma das pedras");
            		DestroyObject(pedra[i]);
            		return 1;
            }
        }
    }
    return 1;
}
Reply
#2

Em vez de
pawn Код:
new Float:Mecanicos[3][4] = {

  {pedra[0], 299.27261, 1423.04456, 8.71771},
  {pedra[1], 294.43201, 1393.79041, 9.17888},
  {pedra[2], 314.09689, 1410.77551, 7.35632},
  {pedra[3], 308.55414, 1385.33337, 8.15589}};
Vocк poderia usar
pawn Код:
new Float:Mecanicos[][] = {
  {false, 299.27261, 1423.04456, 8.71771},
  {false, 294.43201, 1393.79041, 9.17888},
  {false, 314.09689, 1410.77551, 7.35632},
  {false, 308.55414, 1385.33337, 8.15589}
};
Esse false seria para verificar se a pedra jб foi destruнda ou nгo.
Reply
#3

PHP код:
enum mpInfo {
    
mpObjc,
    
Float:mpPos[3]
};
new 
Float:Mecanicos[][mpInfo] = {
  {-
1, {299.272611423.044568.71771}},
  {-
1, {294.432011393.790419.17888}},
  {-
1, {314.096891410.775517.35632}},
  {-
1, {308.554141385.333378.15589}}
};
public 
OnGameModeInit()
{
    for(new 
0sizeof(Mecanicos); i++)
    {
        
Mecanicos[i][mpObjc] = CreateObject(745Mecanicos[i][mpPos][0], Mecanicos[i][mpPos][1], Mecanicos[i][mpPos][2],   0.000000.000000.00000);
    }
    return 
1;
}
public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
newkeys KEY_YES)
    {
        for(new 
0sizeof(Mecanicos); i++)
        {
            if(
IsValidObject(Mecanicos[i][mpObjc])) //checar se a pedra existe
            
{
                if(
IsPlayerInRangeOfPoint(playerid5.0Mecanicos[i][mpPos][0], Mecanicos[i][mpPos][1], Mecanicos[i][mpPos][2]))
                {
                    
SendClientMessage(playerid, -1"Vocк esta no raio de uma das pedras");
                    
DestroyObject(Mecanicos[i][mpObjc]);
                    
Mecanicos[i][mpObjc] = -1//por seguranзa resetar a variбvel (evitar conflito de IDs)
                    
return 1;
                }
            }
        }
    }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)