SA-MP Forums Archive
Need help badly - 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: Need help badly (/showthread.php?tid=157728)



Need help badly - Kayla.S - 07.07.2010

Ok I'm having some problems with too many cars spawning at some checkpoints. I have a map where players use different cars. Once they drive into a checkpoint it deletes their car and puts them into a different one. That works fine, but for some reason after the servers been running for awhile and you drive to the checkpoints on that map you'll see many cars spawned around it. Here's a pic, http://i28.tinypic.com/rmkzlu.png

There's also a checkpoint infront. I just want it so the extra cars don't spawn. Here's the code I have for this and the rest of the checkpoints. Any help would be great thanks.

pawn Код:
if (gCheckpoint[0] == checkpointid)
    {
    new currentveh;
    currentveh = GetPlayerVehicleID(playerid);
    DestroyVehicle(currentveh);
    new Float:X,Float:Y,Float:Z,Float:A;
    GetPlayerPos(playerid,X,Y,Z);
    GetPlayerFacingAngle(playerid,A);
    SpawnedVehicles[playerid] = CreateVehicle(510,X,Y,Z,A,-1,-1,-1);
    SetVehicleVirtualWorld(SpawnedVehicles[playerid], GetPlayerVirtualWorld(playerid));
    PutPlayerInVehicle(playerid,SpawnedVehicles[playerid],0);
    TogglePlayerDynamicCP(playerid, checkpointid, false);
    }



Re: Need help badly - Hiddos - 07.07.2010

Are you sure those players don't disconnect?


Re: Need help badly - Rachael - 07.07.2010

Put a line in OnPlayerDisconnect(playerid) that destroys the vehicle if they crash / quit
also maybe a line in OnPlayerChangeState that checks if oldstate == PLAYER_STATE_DRIVER and newstate == PLAYER_STATE_ONFOOT, and destroy the car then.

etc.

You have to cover every possible outcome.


Re: Need help badly - Kayla.S - 07.07.2010

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
Are you sure those players don't disconnect?
It's something to do with the checkpoint code I'm guessing. Reason is every checkpoint in that map has cars spawned all around it. It's frustrating cause I can't figure out whats causing it. :/ I'm new to scripting but looking at the code it should work. Not sure why it's spawning more of those cars.

Ok thanks Rachael, I'll try that out.