where to put this ?
#1

if(PlayerToPoint(playerid,3453535,3453.45345,345.3 4)
{
SetPlayerPos(playerid,3453.345.,3453,45.345,3434);
}

do i put that at , onplayerupdate ?

this is just an example .. a bunch of numbers .. i just want to know where to put it .. i know the rest
Reply
#2

Definitely not in OnPlayerUpdate. That gets called very quickly. You could call it if you wanted to but it's really unnecessary and might make your server lag. Just use a timer. Call it every second or second and a half or so.

pawn Код:
//At the top
forward Teleport();

//OnGameModeInit
SetTimer("Teleport",1500,1);

public Teleport()
{
   for(new i; i<MAX_PLAYERS; i++)
   {
     if(IsPlayerInRangeOfPoint(i,3453535,3453.45345,345.34)
     {
        SetPlayerPos(i,3453.345.,3453,45.345,3434);
     }
   }
   return 1;
}
Try that out. Don't forget to put the range in.
Reply
#3

Damn it , i almost forgot about timers .. thanks Baked Banana.
Reply
#4

and why do i have to use the 'i' ? whats the difference ? .. mm how about if i make it like .. the largest north Y , lowest south Y .. Lowest X WEst .. the largest X east .. like the turfs .. and if hte player is in that square .. he teleports to the other place ..
how about this ..
forward Teleport(playerid);
public Teleport(playerid)
{
if(IsPlayerInRangeOfPoint(playerid,43.3553,534.53, 534.533);
{
SetPlayerPos(playerid,43.3553,534.53,534.533);
}
return 1;
}

pardon me if i have done any comon mistakes .. i am new in scripting
Reply
#5

Well 'i' is part of the for loop I made. That would loop through all the players and check if any of them are in the range of the point. If you used the code you just posted, it would only work for playerid 0 because that's what it would be by default. And you could do the area way also.

pawn Код:
public Teleport()
{
   new Float:x,Float:y,Float:z;
   for(new i; i<MAX_PLAYERS; i++)
   {
     GetPlayerPos(i,x,y,z);
     if((x > min_x) && (x < max_x) && (y > min_y) && (y < max_y))
     {
        SetPlayerPos(i,3453.345.,3453,45.345,3434);
     }
   }
   return 1;
}
You would have to replace 'min_x' with the maximum x of the area, etc.
Reply
#6

Got it .. thanks alot ... and i have 1 more question .. look when hte player teleports to the certain position we put .... i want to put the SetPlayerFacingAngle(i,?); ... how to find the facing angle coordinate ? which is that ? x, y ?
Reply
#7

You would need to go in game and face the way you want it and use /save. Then check your savepositions.txt in your gta directory. The player angle would be like the 4th number. Or you could just try and get it yourself. The N on your mini map is 360 and the opposite of that is 180.
Reply
#8

Quote:
Originally Posted by Baked-Banana
You would need to go in game and face the way you want it and use /save. Then check your savepositions.txt in your gta directory. The player angle would be like the 4th number. Or you could just try and get it yourself. The N on your mini map is 360 and the opposite of that is 180.
Well the map is like a circle .. and a circle is 360 degrees. so thats easy ..
Reply
#9

i have anotherr question .. lolz
is this ok ? i did it myself ..
did i use the "i" correctly ?
Код:
for(new i; i<MAX_PLAYERS; i++)
  {
  	if(PlayerInfo[i][LoggedIn] == 1 && PlayerInfo[i][Registered] == 1)
		{
	  	if(GetPlayerScore(i) == 50)
	  	{
	    	Gang[i] = BALLA;
	  	}
		}
	}
and i put that at onplayerupdate .. or do i have to make a timer fot this also ?
Reply
#10

Quote:
Originally Posted by Rocky
Quote:
Originally Posted by Baked-Banana
You would need to go in game and face the way you want it and use /save. Then check your savepositions.txt in your gta directory. The player angle would be like the 4th number. Or you could just try and get it yourself. The N on your mini map is 360 and the opposite of that is 180.
Well the map is like a circle .. and a circle is 360 degrees. so thats easy ..
Well that's what I was getting at but I wasn't sure if you would get me.

Quote:
Originally Posted by Rocky
i have anotherr question .. lolz
is this ok ? i did it myself ..
did i use the "i" correctly ?
Код:
for(new i; i<MAX_PLAYERS; i++)
  {
  	if(PlayerInfo[i][LoggedIn] == 1 && PlayerInfo[i][Registered] == 1)
		{
	  	if(GetPlayerScore(i) == 50)
	  	{
	    	Gang[i] = BALLA;
	  	}
		}
	}
and i put that at onplayerupdate .. or do i have to make a timer fot this also ?
You put that under a timer. If you used OnPlayerUpdate you wouldn't need to use i because OnPlayerUpdate gives you the playerid of the player it's updating. The only problem with OnPlayerUpdate is that it checks too fast for something like this. It just wouldn't be necessary.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)