[Ajuda] Retorna string - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: Non-English (
https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (
https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (
https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] Retorna string (
/showthread.php?tid=663553)
Retorna string -
elTioFrame - 04.02.2019
Bom estava criando um sistema de inventбrio sу pra min brincar e me deparei com a seguinte situaзгo, eu criei enum e new informando o id tipo e nome do item, mas quando eu tento getar esse nome do item nгo retorna nada o lugar onde era para aparecer o nome nгo aparece nada (OBS: estou usando o %s) mas msm assim nгo adiantou.
concerteza deve ser algo que eu errei no loop, peзo a ajuda de vocкs!
pawn Код:
GetPlayerItemName(itemid)
{
new name[30];
for(new i; i < sizeof ServerItens; i++)
{
if(ServerItens[i][itemName] == itemid)
{
format(name, sizeof(name), ServerItens[itemid][itemName]);
break;
}
}
return name;
}
Re: Retorna string -
RenanMsV - 04.02.2019
pawn Код:
GetPlayerItemName(itemid)
{
new name[30];
for(new i; i < sizeof ServerItens; i++)
{
if(ServerItens[i][itemName] == itemid) // aqui estб estranho voce esta comparando um id com um nome. provavelmente comparando string com inteiro. talvez checar o valor de i ? return ServerItems[itemid][itemName]
{
format(name, sizeof(name), ServerItens[itemid][itemName]); // troque itemid por i para pegar o nome do item atual
break;
}
}
return name;
}
se o itemid for sempre igual ao index do item nem precisa do loop
pawn Код:
GetPlayerItemName(itemid)
{
new name[30];
format(name, sizeof(name), ServerItens[itemid][itemName]);
return name;
}