[Ajuda] Ajuda com random.
#1

Olб.

Pessoal estou com um problema envolvendo random.

Criei um sistema de entregar pizzas em meu servidor e cada pizza marcada serб em um local aleatуrio, o problema й que quando eu chego no local para entregar a pizza, a mensagem retorna que eu nгo estou no local, mesmo com as funзхes corretas do random.

Irei colocar o cуdigo abaixo e vocкs poderiam dar uma verificar e vк se eu cometi algum erro.

pawn Код:
Float:EntregasPizza[38][3] =
{
    {2200.1003, -1451.6707, 24.3589},
    {940.3124, -708.1927, 122.0105},
    {866.5078, -710.9155, 105.5066},
    {402.2745, -1148.2843, 76.8555},
    {837.4636, -759.5170, 84.9513},
    {2375.2605, -1146.4277, 27.3545},
    {2400.0210, -1136.1881, 29.8213},
    {2422.5791, -1131.1589, 34.1230},
    {2490.6006, -1142.1642, 38.0013},
    {2502.4731, -1133.9078, 38.9480},
    {1855.3026, -2143.7849, 13.2740},
    {1876.6418, -2143.8484, 13.2740},
    {1898.3320, -2143.6541, 13.2740},
    {1899.8561, -2060.0862, 13.2752},
    {1877.6840, -2060.2092, 13.2740},
    {1856.8407, -2060.2251, 13.2739},
    {342.3443, -1876.0426, 2.2556},
    {294.5735, -1876.1187, 1.9910},
    {250.3848, -1875.6232, 1.5720},
    {205.9865, -1876.2771, 1.8068},
    {1184.6124, -1252.5688, 14.9079},
    {799.4169, -1725.1656, 13.1098},
    {1056.5303, -1634.9620, 20.4926},
    {660.4966, -1599.2468, 15.0000},
    {476.1778, -1279.6237, 16.4892},
    {303.5146, -1771.3618, 4.5343},
    {962.0251, -1612.6223, 14.9420},
    {2150.1008, -1416.8749, 25.9219},
    {2440.3147, -1340.3372, 24.1056},
    {2486.3394, -1135.8716, 39.1054},
    {2548.3176, -1034.8008, 69.5813},
    {2631.1831, -1070.2643, 69.6250},
    {2805.8496, -1189.3347, 25.4075},
    {2806.1555, -1177.4073, 25.4350},
    {2804.7275, -1281.5736, 43.8897},
    {2691.6760, -1992.8153, 13.5547},
    {1869.1351, -2035.3472, 13.5469},
    {1710.4744, -2122.9978, 13.5543}
},

CMD:entregarpizza(playerid, params[])
{
    if(INFO_P[playerid][Profissao_P] != 1) return SendClientMessage(playerid, COR_ERRO, ": ERRO : Vocк nгo tem permissгo para usar este comando!");
    if(entregando_pizzas[playerid] == false) return SendClientMessage(playerid, COR_ERRO, ": ERRO : Vocк nгo marcou nenhuma entrega de pizza!");
    new rand = random(sizeof(EntregasPizza));
    if(IsPlayerInRangeOfPoint(playerid, 3, EntregasPizza[rand][0], EntregasPizza[rand][1], EntregasPizza[rand][2]))
    {
        RemovePlayerMapIcon(playerid, 0);
        DestroyDynamic3DTextLabel(PizzaBoy_Text[playerid]);
        DestroyDynamicPickup(PizzaBoy_Pickup[playerid]);           
        new Gorjeta; Gorjeta = random(20);     
        Quantidade_de_Pizza[playerid] -= 1;    
        INFO_P[playerid][Dinheiro_do_Jogador_P] += 100 + Gorjeta;
        INFO_P[playerid][Pizzas_Entregues_P] += 1;
        format(STG,sizeof(STG), ": PIZZARIA : {FFFFFF}Vocк realizou a entrega de uma pizza e ganhou {4EBF72}$100 {FFFFFF}e mais {4EBF72}$%d {FFFFFF}de gorjeta.", Gorjeta);
        SendClientMessage(playerid, 0xFF8C00FF , STG);
        if(Quantidade_de_Pizza[playerid] != 0)
        {      
           
            SetPlayerMapIcon(playerid, 0, EntregasPizza[rand][0], EntregasPizza[rand][1], EntregasPizza[rand][2], 29, 0, MAPICON_GLOBAL);
            PizzaBoy_Pickup[playerid] = CreateDynamicPickup(1582, 23, EntregasPizza[rand][0], EntregasPizza[rand][1], EntregasPizza[rand][2]);
            PizzaBoy_Text[playerid] = CreateDynamic3DTextLabel("/entregarpizza", 0xFF9810FF, EntregasPizza[rand][0], EntregasPizza[rand][1], EntregasPizza[rand][2], 10.0);
            PlayerPlaySound(playerid, 1057, 0, 0, 0);  
            format(STG,sizeof(STG), ": PIZZARIA : {FFFFFF}Vocк possui mais {FF8C00}%d {FFFFFF}entrega(s), siga o icone de pizza que esta em seu mapa.", Quantidade_de_Pizza[playerid]);
            SendClientMessage(playerid, 0xFF8C00FF , STG);                             
        }
        else if(Quantidade_de_Pizza[playerid] < 1)
        {
            SendClientMessage(playerid, 0xFF8C00FF, ": PIZZARIA : {FFFFFF}Vocк concluiu as {FF8C00}3 {FFFFFF}entregas de pizzas que vocк marcou, volte а pizzaria para realizar mais entregas.");
            entregando_pizzas[playerid] = false;           
        }      
        Salvar_Contas(playerid);
    }
    else
    {
        SendClientMessage(playerid, COR_ERRO, ": ERRO : {FFFFFF}Vocк nгo esta no local marcado de entregar pizza!");
    }
    return true;
}

Obrigado
Reply
#2

Faзa debugs para verificar se estб rodando todo o algorнtimo.
Reply
#3

Код:
new rand = random(sizeof(EntregasPizza));
	if(IsPlayerInRangeOfPoint(playerid, 3, EntregasPizza[rand][0], EntregasPizza[rand][1], EntregasPizza[rand][2]))
Mal, voce ta fazendo un check random, nao na posiзao do checkpoint.

Pode pega el codigo que usa para entregar a 'mission'?

Eu falo broken portugues.
Reply
#4

Quote:
Originally Posted by Troydere
Посмотреть сообщение
Код:
new rand = random(sizeof(EntregasPizza));
	if(IsPlayerInRangeOfPoint(playerid, 3, EntregasPizza[rand][0], EntregasPizza[rand][1], EntregasPizza[rand][2]))
Mal, voce ta fazendo un check random, nao na posiзao do checkpoint.

Pode pega el codigo que usa para entregar a 'mission'?

Eu falo broken portugues.
Este й o codigo e o que verifica й o IsplayerInRangeOfPoint.

pawn Код:
CMD:entregarpizza(playerid, params[])
{
    if(INFO_P[playerid][Profissao_P] != 1) return SendClientMessage(playerid, COR_ERRO, ": ERRO : Vocк nгo tem permissгo para usar este comando!");
    if(entregando_pizzas[playerid] == false) return SendClientMessage(playerid, COR_ERRO, ": ERRO : Vocк nгo marcou nenhuma entrega de pizza!");
    new rand = random(sizeof(EntregasPizza));
    if(IsPlayerInRangeOfPoint(playerid, 3, EntregasPizza[rand][0], EntregasPizza[rand][1], EntregasPizza[rand][2]))
    {
        RemovePlayerMapIcon(playerid, 0);
        DestroyDynamic3DTextLabel(PizzaBoy_Text[playerid]);
        DestroyDynamicPickup(PizzaBoy_Pickup[playerid]);           
        new Gorjeta; Gorjeta = random(20);     
        Quantidade_de_Pizza[playerid] -= 1;    
        INFO_P[playerid][Dinheiro_do_Jogador_P] += 100 + Gorjeta;
        INFO_P[playerid][Pizzas_Entregues_P] += 1;
        format(STG,sizeof(STG), ": PIZZARIA : {FFFFFF}Vocк realizou a entrega de uma pizza e ganhou {4EBF72}$100 {FFFFFF}e mais {4EBF72}$%d {FFFFFF}de gorjeta.", Gorjeta);
        SendClientMessage(playerid, 0xFF8C00FF , STG);
        if(Quantidade_de_Pizza[playerid] != 0)
        {      
           
            SetPlayerMapIcon(playerid, 0, EntregasPizza[rand][0], EntregasPizza[rand][1], EntregasPizza[rand][2], 29, 0, MAPICON_GLOBAL);
            PizzaBoy_Pickup[playerid] = CreateDynamicPickup(1582, 23, EntregasPizza[rand][0], EntregasPizza[rand][1], EntregasPizza[rand][2]);
            PizzaBoy_Text[playerid] = CreateDynamic3DTextLabel("/entregarpizza", 0xFF9810FF, EntregasPizza[rand][0], EntregasPizza[rand][1], EntregasPizza[rand][2], 10.0);
            PlayerPlaySound(playerid, 1057, 0, 0, 0);  
            format(STG,sizeof(STG), ": PIZZARIA : {FFFFFF}Vocк possui mais {FF8C00}%d {FFFFFF}entrega(s), siga o icone de pizza que esta em seu mapa.", Quantidade_de_Pizza[playerid]);
            SendClientMessage(playerid, 0xFF8C00FF , STG);                             
        }
        else if(Quantidade_de_Pizza[playerid] < 1)
        {
            SendClientMessage(playerid, 0xFF8C00FF, ": PIZZARIA : {FFFFFF}Vocк concluiu as {FF8C00}3 {FFFFFF}entregas de pizzas que vocк marcou, volte а pizzaria para realizar mais entregas.");
            entregando_pizzas[playerid] = false;           
        }      
        Salvar_Contas(playerid);
    }
    else
    {
        SendClientMessage(playerid, COR_ERRO, ": ERRO : {FFFFFF}Vocк nгo esta no local marcado de entregar pizza!");
    }
    return true;
}
Reply
#5

o qual й el codigo que modifica este valor para true?
Код:
entregando_pizzas[playerid]
Reply
#6

Quote:
Originally Posted by Troydere
Посмотреть сообщение
o qual й el codigo que modifica este valor para true?
Код:
entregando_pizzas[playerid]
Esta й a variбvel do jogador ao pegar 3 pizzas, ela fica como true, assim ele precisa terminar de entregas as 3 para ficar false.
Reply
#7

bom o valor tem que ser flutuante em IsPlayerInRangeOfPoint verifique se й esse o erro e tambйm faзa um debug antes dessa verifiзгo e depois...

Errado:
PHP код:
if(IsPlayerInRangeOfPoint(playerid3EntregasPizza[rand][0], EntregasPizza[rand][1], EntregasPizza[rand][2])) 
Teste
PHP код:
 print("CHEGOU ATЙ AQUI");
if(
IsPlayerInRangeOfPoint(playerid3.0EntregasPizza[rand][0], EntregasPizza[rand][1], EntregasPizza[rand][2]))
{
      print(
"ESTA NA POSIЗГO"); 
Reply
#8

Okokok ja fiquei. Cambia esto:

Код:
if(IsPlayerInRangeOfPoint(playerid, 3, EntregasPizza[rand][0], EntregasPizza[rand][1], EntregasPizza[rand][2]))
por esto:

Код:
if(IsPlayerInRangeOfPoint(playerid, 3, GetPVarFloat(playerid,"PizzaX"), GetPVarFloat(playerid,"PizzaY"), GetPVarFloat(playerid,"PizzaZ")))
Y agrega esto:

PHP код:
            SetPlayerMapIcon(playerid0EntregasPizza[rand][0], EntregasPizza[rand][1], EntregasPizza[rand][2], 290MAPICON_GLOBAL);
            
PizzaBoy_Pickup[playerid] = CreateDynamicPickup(158223EntregasPizza[rand][0], EntregasPizza[rand][1], EntregasPizza[rand][2]);
            
PizzaBoy_Text[playerid] = CreateDynamic3DTextLabel("/entregarpizza"0xFF9810FFEntregasPizza[rand][0], EntregasPizza[rand][1], EntregasPizza[rand][2], 10.0);
            
PlayerPlaySound(playerid1057000);    
            
SetPVarFloat(playerid,"PizzaX",EntregasPizza[rand][0]) // AQUI
            
SetPVarFloat(playerid,"PizzaY",EntregasPizza[rand][1]) // AQUI
            
SetPVarFloat(playerid,"PizzaZ",EntregasPizza[rand][2]) // AQUI
            
format(STG,sizeof(STG), ": PIZZARIA : {FFFFFF}Vocк possui mais {FF8C00}%d {FFFFFF}entrega(s), siga o icone de pizza que esta em seu mapa."Quantidade_de_Pizza[playerid]);
            
SendClientMessage(playerid0xFF8C00FF STG); 
Deveria servir

Desculpa por poca explicaзao, nao sou br.
Reply
#9

Quote:
Originally Posted by Whoo
Посмотреть сообщение
bom o valor tem que ser flutuante em IsPlayerInRangeOfPoint verifique se й esse o erro e tambйm faзa um debug antes dessa verifiзгo e depois...

Errado:
PHP код:
if(IsPlayerInRangeOfPoint(playerid3EntregasPizza[rand][0], EntregasPizza[rand][1], EntregasPizza[rand][2])) 
Teste
PHP код:
 print("CHEGOU ATЙ AQUI");
if(
IsPlayerInRangeOfPoint(playerid3.0EntregasPizza[rand][0], EntregasPizza[rand][1], EntregasPizza[rand][2]))
{
      print(
"ESTA NA POSIЗГO"); 
Eu fiz, porйm sу chega atй aqui

pawn Код:
if(INFO_P[playerid][Profissao_P] != 1) return SendClientMessage(playerid, COR_ERRO, ": ERRO : Vocк nгo tem permissгo para usar este comando!");
    if(entregando_pizzas[playerid] == false) return SendClientMessage(playerid, COR_ERRO, ": ERRO : Vocк nгo marcou nenhuma entrega de pizza!");
    new rand = random(sizeof(EntregasPizza));
    print("CHEGOU ATЙ AQUI");
Reply
#10

Quote:
Originally Posted by Troydere
Посмотреть сообщение
Okokok ja fiquei. Cambia esto:

Код:
if(IsPlayerInRangeOfPoint(playerid, 3, EntregasPizza[rand][0], EntregasPizza[rand][1], EntregasPizza[rand][2]))
por esto:

Код:
if(IsPlayerInRangeOfPoint(playerid, 3, GetPVarFloat(playerid,"PizzaX"), GetPVarFloat(playerid,"PizzaY"), GetPVarFloat(playerid,"PizzaZ")))
Y agrega esto:

PHP код:
            SetPlayerMapIcon(playerid0EntregasPizza[rand][0], EntregasPizza[rand][1], EntregasPizza[rand][2], 290MAPICON_GLOBAL);
            
PizzaBoy_Pickup[playerid] = CreateDynamicPickup(158223EntregasPizza[rand][0], EntregasPizza[rand][1], EntregasPizza[rand][2]);
            
PizzaBoy_Text[playerid] = CreateDynamic3DTextLabel("/entregarpizza"0xFF9810FFEntregasPizza[rand][0], EntregasPizza[rand][1], EntregasPizza[rand][2], 10.0);
            
PlayerPlaySound(playerid1057000);    
            
SetPVarFloat(playerid,"PizzaX",EntregasPizza[rand][0]) // AQUI
            
SetPVarFloat(playerid,"PizzaY",EntregasPizza[rand][1]) // AQUI
            
SetPVarFloat(playerid,"PizzaZ",EntregasPizza[rand][2]) // AQUI
            
format(STG,sizeof(STG), ": PIZZARIA : {FFFFFF}Vocк possui mais {FF8C00}%d {FFFFFF}entrega(s), siga o icone de pizza que esta em seu mapa."Quantidade_de_Pizza[playerid]);
            
SendClientMessage(playerid0xFF8C00FF STG); 
Deveria servir

Desculpa por poca explicaзao, nao sou br.
Gracias, resolvou mi problema.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)