Settext cmd -
SaiyanZ - 06.02.2017
Hello.
I was trying to make /settext [id] [text]
It will just create 3d text on player's head but when i type /text in game it says "Unknown command"
Is there any any problem?
PHP код:
CMD:settext(playerid, params[])
{
new id, string[128];
if(!IsPlayerAdmin(playerid)) return 0;
if(sscanf(params, "ui", id, text)) return SendClientMessage(playerid, -1, "USAGE: /settext [ID] [Text]");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Player not connected!");
if(attachedtext[id]==1) return SendClientMessage(playerid, -1, "SERVER: Player already has a text attached, /deltext first!");
label = Create3DTextLabel(text, 0xAA3333AA, 30.0, 40.0, 50.0, 40.0, 0);
Attach3DTextLabelToPlayer(label, id, 0.0, 0.0, 0.7);
format(string, 128, "SERVER: Text '%s' has appeared on your head", text);
SendClientMessage(id, -1, string);
attachedtext[id]=1;
return 1;
}
Re: Need help -
AndreiWow - 06.02.2017
But the cmd is /settext not /text...
Re: Need help -
SaiyanZ - 06.02.2017
Ah, Just typed wrong in the post
/settext is not working
Also i'm using this cmd in a separate script, if i add this cmd in any other script then the whole script (In which i add this cmd) stops working, like everything in that is "Unknown command"
Re: Need help -
antoaneu - 06.02.2017
You forgot to declare your variable 'text'.
PHP код:
CMD:settext(playerid, params[])
{
new id, string[128], text[128];
if(!IsPlayerAdmin(playerid)) return 0;
if(sscanf(params, "us[128]", id, text)) return SendClientMessage(playerid, -1, "USAGE: /settext [ID] [Text]");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Player not connected!");
if(attachedtext[id] == 1) return SendClientMessage(playerid, -1, "SERVER: Player already has a text attached, /deltext first!");
label = Create3DTextLabel(text, 0xAA3333AA, 30.0, 40.0, 50.0, 40.0, 0);
Attach3DTextLabelToPlayer(label, id, 0.0, 0.0, 0.7);
format(string, 128, "SERVER: Text '%s' has appeared on your head", text);
SendClientMessage(id, -1, string);
attachedtext[id]=1;
return 1;
}
Re: Need help -
SaiyanZ - 06.02.2017
PHP код:
new text[128];
new attachedtext[MAX_PLAYERS];
new Text3D:label;
public OnPlayerConnect(playerid)
{
attachedtext[playerid]=0;
return 1;
}
CMD:settext(playerid, params[])
{
new id, string[128];
if(!IsPlayerAdmin(playerid)) return 0;
if(sscanf(params, "ui", id, text)) return SendClientMessage(playerid, -1, "USAGE: /settext [ID] [Text]");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Player not connected!");
if(attachedtext[id]==1) return SendClientMessage(playerid, -1, "SERVER: Player already has a text attached, /deltext first!");
label = Create3DTextLabel(text, 0xAA3333AA, 30.0, 40.0, 50.0, 40.0, 0);
Attach3DTextLabelToPlayer(label, id, 0.0, 0.0, 0.7);
format(string, 128, "SERVER: Text '%s' has appeared on your head", text);
SendClientMessage(id, -1, string);
attachedtext[id]=1;
return 1;
}
I already had that on the top so i can remove it later with cmd
Re: Need help -
antoaneu - 06.02.2017
Change this line:
PHP код:
if(sscanf(params, "ui", id, text)) return SendClientMessage(playerid, -1, "USAGE: /settext [ID] [Text]");
To this line:
PHP код:
if(sscanf(params, "us[128]", id, text)) return SendClientMessage(playerid, -1, "USAGE: /settext [ID] [Text]");
The specifier 'i' means an integer, however here you want the player to type a text so the specifier will be 's'.