SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 22/10/2019, 10:18 PM   #1
Vizi10
Huge Clucker
 
Join Date: May 2017
Location: Iran
Posts: 276
Reputation: 8
Default Server freezed with foreach

When i respawn all vehicles with foreach loop server has been crashed/freezed.
Why?

pawn Code:
foreach(new i : Vehicle)
{
    SetVehicleToRespawn(i);
}
//This code is in the server timer. For example, when clock is 12:00 pm, this code is used and respawns the vehicles.
Vizi10 is offline   Reply With Quote
Old 23/10/2019, 05:55 AM   #2
SiaReyes
Huge Clucker
 
SiaReyes's Avatar
 
Join Date: Mar 2019
Location: Coordinates X,Y,Z
Posts: 423
Reputation: 32
Default Re: Server freezed with foreach

Try this

https://forum.sa-mp.com/showpost.php...57&postcount=4
__________________
Offshowtime Fuck It!

Quote:
Originally Posted by Toroi View Post
blackmail people that join your server using their ip address as hostage

or get a job and play sa-mp for fun
SiaReyes is offline   Reply With Quote
Old 27/10/2019, 12:45 AM   #3
MP2
Godfather
 
MP2's Avatar
 
Join Date: Jan 2011
Location: England
Posts: 6,230
Reputation: 993
Default Re: Server freezed with foreach

It’s possible that respawning the vehicle inside the iterator loop removes it from the iterator and breaks the loop. You would then need to use Iter_SafeRemove (I think that is the function name) to remove the vehicle from the iterator before respawning it.

As easier option would just be to use a normal for() loop as stated above.
__________________
Click banner above for more info. View trailers here.
Enter referral code SAMPFORUM after registering for a $5000 starting bonus!
MP2 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Connected and logged in to the server, and freezed! StevenLV Scripting Help 0 05/06/2019 01:40 PM
Players gone AFK when freezed TokicMajstor Scripting Help 5 26/04/2019 07:17 PM
Server Freezed Venice Server Support 3 18/09/2014 11:18 PM
GTA-freezed yellow Client Support 1 01/09/2013 06:50 AM


All times are GMT. The time now is 06:53 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.