SA-MP Forums Archive
Problem with my code - 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 my code (/showthread.php?tid=424689)



Problem with my code - Jamcraftadam - 23.03.2013

I recently made a code with an if Statement, but when someone does the command, only THEY can see it? Others are ment to see it when in range, I tried format string.

Код:
CMD:beatup(playerid, params[])
{
	new Float:x, Float:y, Float:z;
	GetPlayerPos(playerid, x, y, z);
	if(IsPlayerInRangeOfPoint(playerid, 20.0, x, y, z))
	{
  		SendClientMessage(playerid, COLOR_TAN, "*A Person Begins to beat up a person");
        PlayAudioStreamForPlayer(playerid, "http://soundfxnow.com/soundfx/FistFight.mp3");
	}
	return 1;
}



Re: Problem with my code - XStormiest - 23.03.2013

pawn Код:
CMD:beatup(playerid, params[])
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    if(IsPlayerInRangeOfPoint(playerid, 20.0, x, y, z))
    {
                foreach(new = 0;i > MAX_PLAYERS;i++)
                {
        SendClientMessage(i, COLOR_TAN, "*A Person Begins to beat up a person");
        PlayAudioStreamForPlayer(i, "http://soundfxnow.com/soundfx/FistFight.mp3");
              }
    }
    return 1;
}



Respuesta: Problem with my code - Xabi - 23.03.2013

You should use a for to see if there is any player in range

pawn Код:
CMD:beatup(playerid, params[])
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && IsPlayerInRangeOfPoint(i, 20.0, x, y, z))
        {
            SendClientMessage(i, COLOR_TAN, "*A Person Begins to beat up a person");
                     PlayAudioStreamForPlayer(i, "http://soundfxnow.com/soundfx/FistFight.mp3");
        }
    }
    return 1;
}



Re: Problem with my code - RenovanZ - 23.03.2013

You want to the player who is in range will send message and play stream ?


Re: Problem with my code - Jamcraftadam - 23.03.2013

Quote:
Originally Posted by XStormiest
Посмотреть сообщение
pawn Код:
CMD:beatup(playerid, params[])
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    if(IsPlayerInRangeOfPoint(playerid, 20.0, x, y, z))
    {
                foreach(new = 0;i > MAX_PLAYERS;i++)
                {
        SendClientMessage(i, COLOR_TAN, "*A Person Begins to beat up a person");
        PlayAudioStreamForPlayer(i, "http://soundfxnow.com/soundfx/FistFight.mp3");
              }
    }
    return 1;
}
C:\Users\Adam Elliott\Desktop\Private Fun Server\filterscripts\cmdtests.pwn(265) : error 017: undefined symbol "foreach"
C:\Users\Adam Elliott\Desktop\Private Fun Server\filterscripts\cmdtests.pwn(265) : error 029: invalid expression, assumed zero
C:\Users\Adam Elliott\Desktop\Private Fun Server\filterscripts\cmdtests.pwn(265) : warning 215: expression has no effect
C:\Users\Adam Elliott\Desktop\Private Fun Server\filterscripts\cmdtests.pwn(265) : error 017: undefined symbol "i"
C:\Users\Adam Elliott\Desktop\Private Fun Server\filterscripts\cmdtests.pwn(265) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.


Re: Problem with my code - RenovanZ - 23.03.2013

Quote:
Originally Posted by Jamcraftadam
Посмотреть сообщение
C:\Users\Adam Elliott\Desktop\Private Fun Server\filterscripts\cmdtests.pwn(265) : error 017: undefined symbol "foreach"
C:\Users\Adam Elliott\Desktop\Private Fun Server\filterscripts\cmdtests.pwn(265) : error 029: invalid expression, assumed zero
C:\Users\Adam Elliott\Desktop\Private Fun Server\filterscripts\cmdtests.pwn(265) : warning 215: expression has no effect
C:\Users\Adam Elliott\Desktop\Private Fun Server\filterscripts\cmdtests.pwn(265) : error 017: undefined symbol "i"
C:\Users\Adam Elliott\Desktop\Private Fun Server\filterscripts\cmdtests.pwn(265) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Download foreach Include, then add it on pawno => includes then add this to your script
pawn Код:
#include <foreach>



Re: Problem with my code - Jamcraftadam - 23.03.2013

Quote:
Originally Posted by Kiyozi_Mu
Посмотреть сообщение
You want to the player who is in range will send message and play stream ?
Yes, basically. local stream and text, but i cant use format string, because it only supports SendClientMessageToAll for me


Re: Problem with my code - HurtLocker - 23.03.2013

You obviously dont have *****'s foreach include. But run xabis's version too and if that doesn't run, download foreach include and run xstormiest's version.


Re: Problem with my code - Jamcraftadam - 23.03.2013

Quote:
Originally Posted by Kiyozi_Mu
Посмотреть сообщение
Download foreach Include, then add it on pawno => includes then add this to your script
pawn Код:
#include <foreach>
C:\Users\Adam Elliott\Desktop\Private Fun Server\filterscripts\cmdtests.pwn(266) : error 001: expected token: ";", but found "||"
C:\Users\Adam Elliott\Desktop\Private Fun Server\filterscripts\cmdtests.pwn(266) : error 001: expected token: ";", but found "new"
C:\Users\Adam Elliott\Desktop\Private Fun Server\filterscripts\cmdtests.pwn(266) : warning 215: expression has no effect
C:\Users\Adam Elliott\Desktop\Private Fun Server\filterscripts\cmdtests.pwn(266) : warning 203: symbol is never used: "Y_FOREACH_SECOND"
C:\Users\Adam Elliott\Desktop\Private Fun Server\filterscripts\cmdtests.pwn(266) : error 017: undefined symbol "i"
C:\Users\Adam Elliott\Desktop\Private Fun Server\filterscripts\cmdtests.pwn(266) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.

Am i missing anything


Re: Problem with my code - RenovanZ - 23.03.2013

Quote:
Originally Posted by Jamcraftadam
Посмотреть сообщение
C:\Users\Adam Elliott\Desktop\Private Fun Server\filterscripts\cmdtests.pwn(266) : error 001: expected token: ";", but found "||"
C:\Users\Adam Elliott\Desktop\Private Fun Server\filterscripts\cmdtests.pwn(266) : error 001: expected token: ";", but found "new"
C:\Users\Adam Elliott\Desktop\Private Fun Server\filterscripts\cmdtests.pwn(266) : warning 215: expression has no effect
C:\Users\Adam Elliott\Desktop\Private Fun Server\filterscripts\cmdtests.pwn(266) : warning 203: symbol is never used: "Y_FOREACH_SECOND"
C:\Users\Adam Elliott\Desktop\Private Fun Server\filterscripts\cmdtests.pwn(266) : error 017: undefined symbol "i"
C:\Users\Adam Elliott\Desktop\Private Fun Server\filterscripts\cmdtests.pwn(266) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.

Am i missing anything
Give the code of lines 266..