SA-MP Forums Archive
Bugged or something wrong - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Bugged or something wrong (/showthread.php?tid=188850)



Bugged or something wrong - Hoss - 09.11.2010

I was going to make a script when train arrives to Los Santos it sends a client message to all:
Heres the code but it has no effect:

pawn Код:
if(IsPlayerInVehicle(playerid,train))
    {
        if(IsPlayerInRangeOfPoint(playerid,10.0,1700.4967 ,-1955.4222,13.5469))
        {
            SendClientMessageToAll(COLOR_RED,"Train is in Los Santos you have 10 minutes to get in train");
            return 1;
            }



Re: Bugged or something wrong - TheXIII - 09.11.2010

Are you actually using the code? Try this:
pawn Код:
//On Top of Script, possibly where other forwards are.
forward TrainCheck();

// On Top of script, Possibly where other global variables are.
new bool:TrainMessageSent;
//Under OnGameModeInit
SetTimer("TrainCheck", 5000, true);
// Anywhere, except in other functions
public TrainCheck()
{
    if(IsPlayerInVehicle(playerid,train))
    {
        if(IsPlayerInRangeOfPoint(playerid,10.0,1700.4967 ,-1955.4222,13.5469))
        {
            if(!TrainMessageSent)
            {
                SendClientMessageToAll(COLOR_RED,"Train is in Los Santos you have 10 minutes to get in train");
                TrainMessageSent = true;
            }
        }
        else TrainMessageSent = false;
    }
}



Re: Bugged or something wrong - Hoss - 09.11.2010

pawn Код:
C:\Documents and Settings\Ðàáî÷èé ñòîë\samp server\gamemodes\~.pwn(551) : error 017: undefined symbol "playerid"
C:\Documents and Settings\Ðàáî÷èé ñòîë\samp server\gamemodes\~.pwn(553) : error 017: undefined symbol "playerid"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase
At these lines:
pawn Код:
if(IsPlayerInVehicle(playerid,train))
    {
        if(IsPlayerInRangeOfPoint(playerid,10.0,1700.4967 ,-1955.4222,13.5469))



Re: Bugged or something wrong - TheXIII - 09.11.2010

Sorry, didn't really read that part of the code
Remove the "IsPlayerInVehicle" part, and instead of IsPlayerInRangeOfPoint, use IsVehicleInRangeOfPoint, with train ID... I'm sure you can find that function with search.

EDIT:
Actually, try this:
pawn Код:
//On Top of Script, possibly where other forwards are.
forward TrainCheck();

// On Top of script, Possibly where other global variables are.
new bool:TrainMessageSent;
//Under OnGameModeInit
SetTimer("TrainCheck", 5000, true);
// Anywhere, except in other functions
public TrainCheck()
{
    new float:tX, float:tY, float:Tz;
    GetVehiclePos(train, tX, tY, tZ);
    if(PointInRangeOfPoint(20, tX, tY, tZ, 1700.4967 ,-1955.4222,13.5469))
        {
            if(!TrainMessageSent)
            {
                SendClientMessageToAll(COLOR_RED,"Train is in Los Santos you have 10 minutes to get in train");
                TrainMessageSent = true;
            }
        }
        else TrainMessageSent = false;
    }
}
//I believe this stock originates from ******, so credits.
stock PointInRangeOfPoint(Float:range, Float:x, Float:y, Float:z, Float:X, Float:Y, Float:Z)
{
    X -= x;
    Y -= y;
    Z -= z;
    return ((X * X) + (Y * Y) + (Z * Z)) < (range * range);
}



Respuesta: Re: Bugged or something wrong - xenowort - 09.11.2010

Quote:
Originally Posted by [MD]Gangster
Посмотреть сообщение
pawn Код:
C:\Documents and Settings\&#208;àáî÷èé ñòîë\samp server\gamemodes\~.pwn(551) : error 017: undefined symbol "playerid"
C:\Documents and Settings\&#208;àáî÷èé ñòîë\samp server\gamemodes\~.pwn(553) : error 017: undefined symbol "playerid"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase
At these lines:
pawn Код:
if(IsPlayerInVehicle(playerid,train))
    {
        if(IsPlayerInRangeOfPoint(playerid,10.0,1700.4967 ,-1955.4222,13.5469))
use
pawn Код:
For(i,MAX_PLAYERS,i++)
{
// Here you code replace playerid for i
}