PDA

View Full Version : with something small


leon44
18/01/2015, 06:23 PM
Hello guys.
what happens is that I wanted to ask them for help,
Will see, I'm doing a mission of parkour and good this is exactly what I want in parkour.

I want that for example if the player falls of the parkour, I want that to half the ground respawn,
I mean that if it falls below the map of the parkour Respawn, Help me Please.

here are the coordinates where I want if the player reaches falling, to those coordinates respawn again:

AddPlayerClass(0,1173.1627,-2065.5620,432.3798,359.3109,0,0,0,0,0,0);

Thanks

Schneider
18/01/2015, 06:53 PM
Use GetPlayerPos to get the players current position, see if the z-value is below the map, then use SetPlayerPos to spawn the player on your coordinates.

leon44
18/01/2015, 06:57 PM
thanks for replying Schneider, someone me said the same but I'm not very good at this, I could help with a code or some tutorial which teach this please, these are the coordinates of spawn Player:

SetPlayerPos(playerid, -1622.7039,673.5800,-4.9063);
SetPlayerFacingAngle(playerid,150.9650);

Schneider
18/01/2015, 07:11 PM
Alright, first of all, go ingame and go the the lowest point of your map and type /save
Open savedpositions.txt in your UserFiles folder and see what the z-coordinate is.

Now in your gamemode you'll have to start a timer with a for example 1 second interval, in the OnGameModeInit() callback:

SetTimer("CheckHeight", 1000, 1);

Then at the bottom of your script, add the following function and edit with your own preferences:

forward CheckHeight();
public CheckHeight()
{
new Float:Z;
for(new i; i<MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
GetPlayerPos(i, Z, Z, Z);
if(Z < LOWEST_COORDINATE) // enter here the lowest z-coordinate
{
SetPlayerPos(i, -1622.7039,673.5800,-4.9063);
SetPlayerFacingAngle(i, 150.9650);
}
}
return 1;
}

leon44
18/01/2015, 08:54 PM
Friend, Thank you for taking your time helping me, but the code that you are giving me it has not me worked,
What is the error? :(

Schneider
18/01/2015, 08:56 PM
I don't what IS the error?
Do you get an error when you compile, or doesn't it work ingame?

leon44
18/01/2015, 09:16 PM
Look, I put the that code are you giving me and gave me this error compiling:

D:\Desktop\Archives\Gamemodes\Server\gamemodes\Par kour.pwn(677) : error 017: undefined symbol "LOWEST_COORDINATE"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


1 Error.


And to eliminate this error i did this:

new LOWEST_COORDINATE;

and the error is eliminated, then i went to the game to try to see if it worked but it turns out it did not work :/

Schneider
18/01/2015, 09:20 PM
:P
No, read the first part of my post and read what I wrote in that function: // enter here the lowest z-coordinate"

You have to actually write down the lowest coordinate there. :)

leon44
18/01/2015, 11:22 PM
Just like me you said I did., but it did not work I look, here this the coordinates that I use:

Coordinates Spawn Player:

SetPlayerPos(playerid,1173.1627,-2065.5620,432.3798);
SetPlayerFacingAngle(playerid, 359.3109);

Coordinates of the fall of parkour:

AddPlayerClass(104,1198.9684,-2022.5673,351.9539,74.8250,0,0,0,0,0,0);

Then I did the code in this way:

forward CheckHeight();
public CheckHeight()
{
new Float:Z;
for(new i; i<MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
GetPlayerPos(i, Z, Z, Z);
if(74.8250 < LOWEST_COORDINATE) // ''74.8250, Are the coordinates ''Z'' the falling of parkour
{
SetPlayerPos(i,1173.1627,-2065.5620,432.3798);
SetPlayerFacingAngle(i, 359.3109);
}
}
return 1;
}

what's wrong? :/

Schneider
18/01/2015, 11:36 PM
if(Z < 74.8250)

leon44
18/01/2015, 11:40 PM
I already did so but still not working :(

Schneider
19/01/2015, 12:25 AM
Show the code you have now

leon44
19/01/2015, 12:30 AM
Here Is.

forward CheckHeight();
public CheckHeight()
{
new Float:Z;
for(new i; i<MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
GetPlayerPos(i, Z, Z, Z);
if(Z < 74.8250)
{
SetPlayerPos(i,1173.1627,-2065.5620,432.3798);
SetPlayerFacingAngle(i, 359.3109);
}
}
return 1;
}

leon44
19/01/2015, 03:26 PM
Help please :(

zaibaslr2
19/01/2015, 03:38 PM
forward CheckHeight();
public CheckHeight()
{
new Float:PosX,Float:PosY,Float:PosZ;
for(new i; i<MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
GetPlayerPos(i, PosX,PosY,PosZ);
if(PosZ < 74.8250)
{
SetPlayerPos(i,1173.1627,-2065.5620,432.379);
SetPlayerFacingAngle(i, 359.3109);
}
}
return 1;
}
That should work

leon44
19/01/2015, 03:43 PM
thank you very much for responding, but not grab me the code you gave me :c

Schneider
19/01/2015, 03:45 PM
Did you add the timer at OnGameModeInit?

zaibaslr2
19/01/2015, 03:45 PM
Did u launch the timer itself?

SetTimer("CheckHeight", 1000, 1);
Oh sorry didn't see your reply Schneider.

leon44
19/01/2015, 03:48 PM
If the timer I have it in OnGameModeInit:

SetTimer("CheckHeight", 1000, 1);

Schneider
19/01/2015, 03:58 PM
Are you sure the coordinates are right?

The code works fine if I added my own coordinates (in this case the top of the highest building in los santos. If I jump from the roof and fall below 300.0, , it spawns me back on the roof.


forward CheckHeight();
public CheckHeight()
{
new Float:Z;
for(new i; i<MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
GetPlayerPos(i, Z, Z, Z);
if(Z < 300.0) // enter here the lowest z-coordinate
{
SetPlayerPos(i, 1553.9445,-1355.8949,329.4585);
SetPlayerFacingAngle(i, 252.9794);
}
}
return 1;
}

leon44
19/01/2015, 04:10 PM
SOLVED | thank you very much to both And +Rep