is this command wrong?
#1

pawn Код:
CMD:dice(playerid,params[])
{
new rand = random(12);
new sendername[MAX_PLAYER_NAME], message[128];
format(message, sizeof(message), "%s(%d) tries his luck and throws the dice, The dice landed on the number %d",sendername,playerid,rand);
ProxDetector(30.0, playerid, message,COLOR_LAWNGREEN,COLOR_LAWNGREEN,COLOR_LAWNGREEN,COLOR_LAWNGREEN,COLOR_LAWNGREEN);
return 1;
}
CMD:ad(playerid,params[])
{
new sendername[MAX_PLAYER_NAME], string[28];
format(string, sizeof(string),"ADVERTIESMENT: %s, contact %s (ID:%d)",params,sendername,playerid);
SendClientMessageToAll(COLOR_ORANGE,string);
return 1;
}
guys tell me is this code wrong

it does compile but it does not show my name, in the commad /ad it does not show my name and id,and in command /dice it shows only the ID

need help in this
Reply
#2

Seems legit
Reply
#3

Add this after variables (or before the "format")
pawn Код:
GetPlayerName(playerid, sendername, sizeof(sendername));
Reply
#4

Edit: /\

You are not getting player's name.

pawn Код:
CMD:ad(playerid,params[])
{
    new sendername[MAX_PLAYER_NAME], string[28];
    GetPlayerName(playerid, sendername, MAX_PLAYER_NAME);//<<<<<
    format(string, sizeof(string),"ADVERTIESMENT: %s, contact %s (ID:%d)",params,sendername,playerid);
    SendClientMessageToAll(COLOR_ORANGE,string);
    return 1;
}
Obs. Your string array is too short, will not print all characters.
Reply
#5

Yes, you forgot to get the player's name + on the AD command, you used "params" in the format, but I dont see it defined anywhere. For this code to work you need also sscanf2.

pawn Код:
CMD:dice(playerid,params[])
{
    new rand = random(12);
    new sendername[MAX_PLAYER_NAME], message[128];
    GetPlayerName(playerid, sendername, sizeof(sendername));
    format(message, sizeof(message), "%s(%d) tries his luck and throws the dice, The dice landed on the number %d",sendername,playerid,rand);
    ProxDetector(30.0, playerid, message,COLOR_LAWNGREEN,COLOR_LAWNGREEN,COLOR_LAWNGREEN,COLOR_LAWNGREEN,COLOR_LAWNGREEN);
    return 1;
}

CMD:ad(playerid,params[])
{
    new sendername[MAX_PLAYER_NAME], string[64], ad[64];
    GetPlayerName(playerid, sendername, sizeof(sendername));
    if(sscanf(params,"s[64]", ad)) return SendClientMessage(playerid, FFFFFF, "Usage: /ad [text]");
   
    format(string, sizeof(string),"ADVERTISEMENT: %s, contact %s (ID:%d)", ad, sendername, playerid);
    SendClientMessageToAll(COLOR_ORANGE, string);
    return 1;
}
Reply
#6

@dan,and @Ruigy your code is complying but when i type a message like

/ad Cops are after me trying to catch me

it only displays like

ADVERTISEMESNT: Cops are

in short it does not display the whole message
Reply
#7

Quote:
Originally Posted by RuiGy
Посмотреть сообщение
Obs. Your string array is too short, will not print all characters.
pawn Код:
CMD:ad(playerid,params[])
{
    new sendername[MAX_PLAYER_NAME], string[144];// <<<<
    GetPlayerName(playerid, sendername, MAX_PLAYER_NAME);
    format(string, sizeof(string),"ADVERTIESMENT: %s, contact %s (ID:%d)",params,sendername,playerid);
    SendClientMessageToAll(COLOR_ORANGE,string);
    return 1;
}
Reply
#8

pawn Код:
CMD:ad(playerid,params[])
{
    new sendername[MAX_PLAYER_NAME], string[64], ad[144];
    GetPlayerName(playerid, sendername, sizeof(sendername));
    if(sscanf(params,"s[64]", ad)) return SendClientMessage(playerid, FFFFFF, "Usage: /ad [text]");
   
    format(string, sizeof(string),"ADVERTISEMENT: %s, contact %s (ID:%d)", ad, sendername, playerid);
    SendClientMessageToAll(COLOR_ORANGE, string);
    return 1;
}
Reply
#9

here you go it outcomes like this

Reply
#10

pawn Код:
CMD:ad(playerid,params[])
{
    new sendername[MAX_PLAYER_NAME], string[128], ad[128];
    GetPlayerName(playerid, sendername, sizeof(sendername));
    if(sscanf(params,"s[64]", ad)) return SendClientMessage(playerid, FFFFFF, "Usage: /ad [text]");
   
    format(string, sizeof(string),"ADVERTISEMENT: %s, contact %s (ID:%d)", ad, sendername, playerid);
    SendClientMessageToAll(COLOR_ORANGE, string);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)