SA-MP Forums Archive
playerid problem - 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: playerid problem (/showthread.php?tid=292291)



playerid problem - marko94 - 23.10.2011

I'm trying to make a filterscript but if I add something under public OnFilterScriptInit(), everytime I compile it I get this error:

Код:
error 017: undefined symbol "playerid"
pawn Код:
if (PlayerToPoint(5.0, playerid, 757.7714, -1996.8455, -0.3859))
    {
        GivePlayerMoney(playerid, 2500);
    }
What can I do about this?


Re: playerid problem - Join7 - 23.10.2011

Add this

Код:
PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
	new Float:oldposx, Float:oldposy, Float:oldposz,
		Float:tempposx, Float:tempposy, Float:tempposz;
	GetPlayerPos(playerid, oldposx, oldposy, oldposz);
	tempposx = (oldposx -x);
	tempposy = (oldposy -y);
	tempposz = (oldposz -z);
	if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
	{
		return 1;
	}
	return 0;
}
In public OnPlayerCommandText(playerid, cmdtext[])

if (PlayerToPoint(5.0, playerid, 757.7714, -1996.8455, -0.3859))
{
GivePlayerMoney(playerid, 2500);
}


Re: playerid problem - Wesley221 - 23.10.2011

Quote:
Originally Posted by Join7
Посмотреть сообщение
Add this

Код:
PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
	new Float:oldposx, Float:oldposy, Float:oldposz,
		Float:tempposx, Float:tempposy, Float:tempposz;
	GetPlayerPos(playerid, oldposx, oldposy, oldposz);
	tempposx = (oldposx -x);
	tempposy = (oldposy -y);
	tempposz = (oldposz -z);
	if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
	{
		return 1;
	}
	return 0;
}
That doesnt have anything to do with the error.

The callback OnFilterScriptInit doesnt support the parameter 'playerid'. What do you want to do with the piece of code you have? When the player spawns at a certain position, he gets that amount of money or?


Re: playerid problem - SmiT - 23.10.2011

Well, you can't add that under "OnFilterScriptInit". What do you actually wanna do? You can create a function and add a timer that will call the function every second, that will check your position.

EDIT: Wesley was faster.


Re: playerid problem - Join7 - 23.10.2011

In public OnPlayerCommandText(playerid, cmdtext[])

if (PlayerToPoint(5.0, playerid, 757.7714, -1996.8455, -0.3859))
{
GivePlayerMoney(playerid, 2500);
}


Re: playerid problem - SmiT - 23.10.2011

That makes no sense Join7.


Re: playerid problem - marko94 - 23.10.2011

Yes, I'm trying to check if the player is in a certain position so he will recieve an amount of money/a weapon only when he's in that range of point(If we walks/swims in there, drives a car/boat near the point etc). If I add it under OnPlayerCommandText it works but only when I'm typing a command. Same goes for OnPlayerText etc.

EDIT: I added a timer and it works just fine now for what I'm trying to do. Thank you very much. I'll post here for further problems. Thanks once again!


Re: playerid problem - SmiT - 23.10.2011

Well, as I said use a timer. Here is an example using y_timers:
pawn Код:
timer CheckPosition[1000]()
{
    for ( new i = 0; i != MAX_PLAYERS; ++i )
    {
        if ( PlayerToPoint(5.0, i, 757.7714, -1996.8455, -0.3859 ) )
        {
            GivePlayerMoney(i, 2500);
        }
    }
}

public OnFilterScriptInit()
{
    repeat CheckPosition();
    return true;
}



Re: playerid problem - marko94 - 23.10.2011

It works just fine now SmiT, thank you.


P.S. Is there any way to make an object move/face the player if the player is in the range?


Re: playerid problem - Zonoya - 23.10.2011

use MoveObject and SetObjectRot or if ur using 0.3d RC6 just use MoveObject