SA-MP Forums Archive
Problem with one command.. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem with one command.. (/showthread.php?tid=569521)



Problem with one command.. - dundolina - 31.03.2015

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;
}



Re: Problem with one command.. - BleverCastard - 31.03.2015

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.


Re: Problem with one command.. - dundolina - 31.03.2015

Код:
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.



Re: Problem with one command.. - CalvinC - 31.03.2015

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


Re: Problem with one command.. - BleverCastard - 31.03.2015

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.


Re: Problem with one command.. - Gammix - 31.03.2015

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