Need help
#1

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(playeridparams[])
    {
    new 
idstring[128];
    if(!
IsPlayerAdmin(playerid)) return 0;
    if(
sscanf(params"ui"idtext)) 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(text0xAA3333AA30.040.050.040.00);
    
Attach3DTextLabelToPlayer(labelid0.00.00.7);
    
format(string128"SERVER: Text '%s' has appeared on your head"text);
    
SendClientMessage(id, -1string);
    
attachedtext[id]=1;
    return 
1;

Reply
#2

But the cmd is /settext not /text...
Reply
#3

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"
Reply
#4

You forgot to declare your variable 'text'.

PHP код:
CMD:settext(playeridparams[])

    new 
idstring[128], text[128]; 
    if(!
IsPlayerAdmin(playerid)) return 0
    if(
sscanf(params"us[128]"idtext)) 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(text0xAA3333AA30.040.050.040.00); 
    
Attach3DTextLabelToPlayer(labelid0.00.00.7); 
    
format(string128"SERVER: Text '%s' has appeared on your head"text); 
    
SendClientMessage(id, -1string); 
    
attachedtext[id]=1
    return 
1

Reply
#5

PHP код:
new text[128];
new 
attachedtext[MAX_PLAYERS];
new 
Text3D:label;
public 
OnPlayerConnect(playerid)
{
    
attachedtext[playerid]=0;
    return 
1;
}
CMD:settext(playeridparams[])
{
    new 
idstring[128];
    if(!
IsPlayerAdmin(playerid)) return 0;
    if(
sscanf(params"ui"idtext)) 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(text0xAA3333AA30.040.050.040.00);
    
Attach3DTextLabelToPlayer(labelid0.00.00.7);
    
format(string128"SERVER: Text '%s' has appeared on your head"text);
    
SendClientMessage(id, -1string);
    
attachedtext[id]=1;
    return 
1;

I already had that on the top so i can remove it later with cmd
Reply
#6

Change this line:
PHP код:
if(sscanf(params"ui"idtext)) return SendClientMessage(playerid, -1"USAGE: /settext [ID] [Text]"); 
To this line:
PHP код:
if(sscanf(params"us[128]"idtext)) 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'.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)