SA-MP Forums Archive
Spawning at random place - 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: Spawning at random place (/showthread.php?tid=510361)



Spawning at random place - Ananisiki - 30.04.2014

I have spec system there it save the latest x, y, z position, when you go off spec you are suposed to spawn there but i dont, i spawn instead at here


pawn Код:
//onplayerspawn
    if(InDMS[playerid] == 1)
    {
        new DMSRandom = random(sizeof(RandomDMSpawns));
        SetPlayerPos(playerid, RandomDMSpawns[DMSRandom][0], RandomDMSpawns[DMSRandom][1], RandomDMSpawns[DMSRandom][2]);
        SetPlayerFacingAngle(playerid, RandomDMSpawns[DMSRandom][3]);
        SetTimer("DMSTimer", 3000, false);
    }



Re: Spawning at random place - Luis- - 30.04.2014

That's no use at all, we'd need the spec off command and how you save the last player coord.


Re: Spawning at random place - Ananisiki - 30.04.2014

pawn Код:
//specoff command
    SetPlayerPos(playerid, SpecX[playerid], SpecY[playerid], SpecZ[playerid]);
    SetPlayerInterior(playerid, SpecInterior[playerid]);
    SetPlayerVirtualWorld(playerid, SpecVWorld[playerid]);

//spec command     
GetPlayerPos(playerid, SpecX[playerid], SpecY[playerid], SpecZ[playerid]);
        SpecInterior[playerid] = GetPlayerInterior(playerid);
        SpecVWorld[playerid] = GetPlayerVirtualWorld(playerid);



Re: Spawning at random place - Luis- - 30.04.2014

You could try setting a timer when you spec off, for around 200ms and in the timer set the players position to their last one, that's what I do, and it seems to work fine.


Re: Spawning at random place - Ananisiki - 30.04.2014

Hm... Dont really understand


Re: Spawning at random place - Luis- - 30.04.2014

Example:
pawn Код:
CMD:specoff(playerid) {
// TogglePlayerSpec and all the other stuff here.
SetTimerEx("SpecOffSpawn", 200, false, "i", playerid);
return 1;
}

forward SpecOffSpawn(playerid);
public SpecOffSpawn(playerid) {
    SetPlayerPos(playerid, SpecX[playerid], SpecY[playerid], SpecZ[playerid]);
    SetPlayerInterior(playerid, SpecInterior[playerid]);
    SetPlayerVirtualWorld(playerid, SpecVWorld[playerid]);
return 1;
}



Re: Spawning at random place - Ananisiki - 30.04.2014

And remove all other setplayerpos, interior etc from spec command and specoff?


Re: Spawning at random place - Luis- - 30.04.2014

No no, keep it on the spec on command, but remove it from the spec off command, just keep the timer on there and the rest of the spec related stuff.


Re: Spawning at random place - Ananisiki - 30.04.2014

Thanks man +rep


Re: Spawning at random place - Ananisiki - 06.05.2014

i need help with this, no work :/