PDA

View Full Version : /cnnnn Problem.


Alpay0098
15/06/2015, 10:14 AM
Hi guys,
First I show my CMD :
if(strcmp(cmd, "/cnnnn", true) == 0)
{
if(PlayerInfo[playerid][pAdmin] >= 3)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "Dastoor: /cnnnn <text> ");
return 1;
}
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[128];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
format(string, sizeof(string), "%s",result);
foreach (Player, i)
{
if(IsPlayerConnected(i) == 1)
{
displayCenterHUDInfo(i, string, 5);
}
}
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, " Shoma dastresie kafi baraye anjame inkar ra nadarid !");
return 1;
}
}

The problem is here that, When I type "/cnnnn Hi Guys" for example, It only shows "Guys" word.
I want to get "Hi Guys" not only "Guys".
Also , displayCenterHUDInfo is like SendClientMessage ...
+Rep for the best answer.

bgedition
15/06/2015, 11:10 AM
Explain more for displayCenterHUDInfo, please.

Alpay0098
15/06/2015, 11:38 AM
It's just a function like SendClientMessage that shows a text :|

bgedition
15/06/2015, 11:45 AM
displayCenterHUDInfo(i, string, 5); - what it means the last parameter?(5)

Ritzy2K
15/06/2015, 11:48 AM
Why do u use old school methods?

:-/ :confused:

bgedition
15/06/2015, 11:51 AM
@[ND]xXZeusXx Iwonder why, too. Use ZCMDand Sscanf

Dutheil
15/06/2015, 11:52 AM
Please, use a processor commands (zcmd, mcmd or an another) and sscanf...

Alpay0098
15/06/2015, 12:47 PM
If I could, make sure I would do that :|
If you can , please share it!

bgedition
15/06/2015, 04:04 PM
Try this.
CMD:cnnnn(playerid, params[]) {
new Text[129];
if(!PLayerInfo[playerid][pAdmin] >= 3) return SendClientMessage(playerid, -1, "Shoma dastresie kafi baraye anjame inkar ra nadarid !");
if(sscanf(params, "s[128]", Text)) return SendClientMessage(playerid, -1, "Dastoor: /cnnnn <text> ");
foreach(Player, x) {
if(IsPlayerConnected(x)) {
SendClientMessage(x, -1, Text); //IDK I think your mistake is in 'displayCenterHUDInfo' where the last param is 5.
}
}
return 1;
}
There are the links:
ZCMD (http://forum.sa-mp.com/showthread.php?t=91354) by ZeeX.
SSCANF (http://forum.sa-mp.com/showthread.php?t=570927) by ******.

Alpay0098
15/06/2015, 04:27 PM
Try this.
CMD:cnnnn(playerid, params[]) {
new Text[129];
if(!PLayerInfo[playerid][pAdmin] >= 3) return SendClientMessage(playerid, -1, "Shoma dastresie kafi baraye anjame inkar ra nadarid !");
if(sscanf(params, "s[128]", Text)) return SendClientMessage(playerid, -1, "Dastoor: /cnnnn <text> ");
foreach(Player, x) {
if(IsPlayerConnected(x)) {
SendClientMessage(x, -1, Text); //IDK I think your mistake is in 'displayCenterHUDInfo' where the last param is 5.
}
}
return 1;
}
There are the links:
ZCMD (http://forum.sa-mp.com/showthread.php?t=91354) by ZeeX.
SSCANF (http://forum.sa-mp.com/showthread.php?t=570927) by ******.


Last parameter is about Time. (How many seconds that message should stay on players screens)
Anyway , I'm going to try this ...

Alpay0098
15/06/2015, 04:38 PM
I did it, but there's a compile error :

CMD:cnnnn(playerid, params[])
{
new Text[129];
if(!PlayerInfo[playerid][pAdmin] >= 3) return SendClientMessage(playerid, COLOR_GRAD1 , "Shoma dastresie kafi baraye anjame inkar ra nadarid !"); // This Line : Tag Mismatch
if(sscanf(params, "s[128]", Text)) return SendClientMessage(playerid, COLOR_GRAD1 , "Dastoor: /cnnnn <text> ");
foreach(Player, x)
{
if(IsPlayerConnected(x))
{
displayCenterHUDInfo(x, Text, 5);
}
}
return 1;
}

Overhaul
15/06/2015, 04:50 PM
That's an outdated foreach syntax.


foreach(new x : Player)


There is no reason to check whether or not player x is connected. Foreach does that internally.

kristo
15/06/2015, 05:11 PM
if(!PlayerInfo[playerid][pAdmin] >= 3)
This basically checks if a boolean value is bigger than or equal to three. Change it to:
if(PlayerInfo[playerid][pAdmin] < 3)

Alpay0098
15/06/2015, 05:34 PM
Thank you guys, my problem is Okay now.
I'll rep all of you guys ASAP. (Due to reputation anti flood :o)

Konstantinos
15/06/2015, 05:35 PM
There's no reason to use sscanf when the commands needs only 1 (string) parameter - use isnull instead.


CMD:cnnnn(playerid, params[])
{
if (PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_GRAD1, " Shoma dastresie kafi baraye anjame inkar ra nadarid !");;
if (isnull(params)) return SendClientMessage(playerid, COLOR_WHITE, "Dastoor: /cnnnn <text> ");

foreach(new i : Player) displayCenterHUDInfo(i, params, 5);
return 1;
}