Problem with one command..
#1

Hello i have one problem with one of the commands in my server. When i write the command dont give me 1 message to all server and give me many many and the chat bug : http://prikachi.com/images/994/8017994V.jpg and this is the command :

Код:
 	if(strcmp(cmd,"/givescoreall",true) == 0)
	{
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
        SendClientMessage(playerid, COLOR_WHITE, "ИЗПОЛЗВАЙ: /givescoreall [ точки ]");
        return 1;
    }
    new kills1;
    kills1 = strval(tmp);
    if(PlayerInfo[playerid][pAdmin] < 5) return  SendClientMessage(playerid, -1, "Нямаш достатъчно права, за да използваш командата!");
    for(new i; i < MAX_PLAYERS; i++)
    {
        PlayerInfo[i][pKills] += kills1;
        SetPlayerScore(i, PlayerInfo[i][pKills]);
    	format(string, sizeof(string), "%s даде %d точки на всички играчи в сървъра!", PlayerName(playerid), PlayerInfo[i][pKills]);
		SendClientMessageToAll(COLOR_RED,string);
    }
    return 1;
}
Reply
#2

pawn Код:
if(strcmp(cmd,"/givescoreall",true) == 0)
    {
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
        SendClientMessage(playerid, COLOR_WHITE, "ИЗПОЛЗВАЙ: /givescoreall [ точки ]");
        return 1;
    }
    new kills1;
    kills1 = strval(tmp);
    if(PlayerInfo[playerid][pAdmin] < 5) return  SendClientMessage(playerid, -1, "Нямаш достатъчно права, за да използваш командата!");
    for(new i; i < MAX_PLAYERS; i++)
    {
        PlayerInfo[i][pKills] += kills1;
        SetPlayerScore(i, PlayerInfo[i][pKills]);
    }
format(string, sizeof(string), "%s даде %d точки на всички играчи в сървъра!", PlayerName(playerid), PlayerInfo[i][pKills]);
        SendClientMessageToAll(COLOR_RED,string);
    return 1;
}
Remove it from the loop.
Reply
#3

Код:
D:\Shefa\Igri\GTASanAndreasRIP\bam\gamemodes\gangwars4.pwn(10784) : error 017: undefined symbol "i"
D:\Shefa\Igri\GTASanAndreasRIP\bam\gamemodes\gangwars4.pwn(10804) : error 017: undefined symbol "i"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Reply
#4

I don't understand the text, but i think you can just use tmp.
Reply
#5

pawn Код:
if(strcmp(cmd,"/givescoreall",true) == 0)
    {
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
        SendClientMessage(playerid, COLOR_WHITE, "ИЗПОЛЗВАЙ: /givescoreall [ точки ]");
        return 1;
    }
    new kills1;
    kills1 = strval(tmp);
    if(PlayerInfo[playerid][pAdmin] < 5) return  SendClientMessage(playerid, -1, "Нямаш достатъчно права, за да използваш командата!");
    for(new i; i < MAX_PLAYERS; i++)
    {
        PlayerInfo[i][pKills] += kills1;
        SetPlayerScore(i, PlayerInfo[i][pKills]);
    }
format(string, sizeof(string), "%s даде %d точки на всички играчи в сървъра!", PlayerName(playerid), PlayerInfo[playerid][pKills]);
        SendClientMessageToAll(COLOR_RED,string);
    return 1;
}
Last time I'm fixing it, learn yourself.
Reply
#6

Why don't you use sscanf(https://sampforum.blast.hk/showthread.php?tid=120356) and zcmd(https://sampforum.blast.hk/showthread.php?tid=91354). Much easier and quiet faster, moreover make your life easier!

Tutorial: https://sampforum.blast.hk/showthread.php?tid=280476 <<How to use
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)