Can anyone help? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Server (
https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (
https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: Can anyone help? (
/showthread.php?tid=318087)
Can anyone help? -
necrobg3 - 13.02.2012
Hello. Today i try to make a command whit 3D Text Label... i attach it and type text in it. -> Create3DTextLabel(" MY TEXT"); . All done but i want to make that command to be used in-game. I mean can anyone tell me how to make the command to set 3d text labels in-game? Like /set3dtext playerid text ?
Re: Can anyone help? -
liinor - 13.02.2012
here is example but it has little problem lol
pawn Код:
new Stexttarget[MAX_PLAYERS]; // on top
pawn Код:
new cmd[256];
if(strcmp(cmd, "/set3dtext", true) == 0)
{
new tmp[256],idx;
tmp = strtok(cmdtext, idx);
Stexttarget[playerid] = strval(tmp);
ShowPlayerDialog(playerid,535,DIALOG_STYLE_INPUT,"TextLabel Fun","Input ID","Ok","Cancel");
return 1;
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 534)
{
if(!response) return SendClientMessage(playerid, 0xFFFFFFFF, "You canceled!");
new message[128];
new Float:X, Float:Y, Float:Z;
GetPlayerPos(Stexttarget[playerid], X, Y, Z );
new Text3D:label = Create3DTextLabel(inputtext,0x008080FF,X,Y,Z, 40.0, 0);
Attach3DTextLabelToPlayer(label,Stexttarget[playerid], 0.0, 0.0, 0.7);
format(message, sizeof(message), "You entered: %s", inputtext);
SendClientMessage(playerid, 0xFFFFFFFF, message);
return 1;
}
if(dialogid == 535)
{
if(!response) return SendClientMessage(playerid, 0xFFFFFFFF, "You canceled!");
new idx;
new tmp[256];
tmp = strtok(inputtext, idx);
if(!IsNumeric(tmp))
{
SendClientMessage(playerid, 0xAA3333AA, "ID Must be a number");
return 1;
}
if(strval(tmp) == Stexttarget[playerid])
{
ShowPlayerDialog(playerid,534,DIALOG_STYLE_INPUT,"TextLabel Fun","text:","Ok","Cancel");
}
else
{
SendClientMessage(playerid, 0xAA3333AA, "That player is not connected!");
}
return 1;
}
return 1;
}
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
new Text3D:label
Delete3DTextLabel(Text3D:label);
return 1;
}
pawn Код:
IsNumeric(const string[])
{
for (new i = 0, j = strlen(string); i < j; i++)
{
if (string[i] > '9' || string[i] < '0') return 0;
}
return 1;
}
Re: Can anyone help? -
necrobg3 - 14.02.2012
i do what u say but it tells me that.
pawn Код:
error 001: expected token: ";", but found "-identifier-"
error 017: undefined symbol "strtok"
error 033: array must be indexed (variable "tmp")
warning 203: symbol is never used: "idx"
error 017: undefined symbol "strtok"
error 033: array must be indexed (variable "tmp")
warning 203: symbol is never used: "idx"
Re: Can anyone help? -
Konstantinos - 14.02.2012
1st error on this callback
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
new Text3D:label; // It didn't have ";"
Delete3DTextLabel(Text3D:label);
return 1;
}
2nd error define the strtok
pawn Код:
// At The Bottom
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}