Comments (7)
Try: if(id == -1)
-1 means the iterator is full. Technically the end of the iterator doesn't mean it is full, but I see what you were trying to do.
from ysi-includes.
I know. I always use if(id == -1)
. You can see first code. Here is solution with id == -1
but it doesn't work. I don't know why.
from ysi-includes.
Try:
stock SellPlayerVehicle(playerid, modelid){
new id = Iter_Free(PlayerVehicle[playerid]);
if(Iter_Add(PlayerVehicle[playerid], id) == -1) return -1;
MsgF(playerid, -1, "SellPlayerVehicle - %d", id);
Also, study up on multi-iterators. You shouldn't be using an iterator array for this vehicle ownership thing. Multiple players can't own the same vehicle (I'm guessing, if they can your script is weird), so a multi-iterator would be easiest to handle.
from ysi-includes.
Iter_Add
and Iter_Free
return cellmin
on failure:
The reason is that -1
is now considered a valid value for some iterators. In fact cellmin
could be, but is less likely to be. I like cellmin
because it has no opposite value - it is NOT -cellmax
(that is cellmin + 1
. In fact, it is more like -0
, so I use it for invalid values.
This iterator will happily return -1
as a valid value:
from ysi-includes.
What? Maybe that's why I was facing so many bugs not long ago. I've been using -1.
How should a -1 situation be dealt with if it is somehow valid? Like, my script only requires indexes 0-99. Should I be checking for cellmin
too?
@PatchwerkQWER: The correct code would be:
stock SellPlayerVehicle(playerid, modelid){
new id = Iter_Free(PlayerVehicle[playerid]);
if(Iter_Add(PlayerVehicle[playerid], id) == cellmin) return -2;
MsgF(playerid, -1, "SellPlayerVehicle - %d", id);
from ysi-includes.
Just because your script only needs 0-99 doesn't mean they all do. -1 is in theory valid in some iterators - even if you don't personally use it y_iterate still has to handle it, and does.
from ysi-includes.
@Crayder You don't know how work my Vehicle System. It doesn't depend on vehicle id. So I doesn't need new multi iterator.
@Y-Less Okay, now it works.So, Can I use everywhere cellmin
istead of -1
? (If I get it)
from ysi-includes.
Related Issues (20)
- I found a problem in y_inline_bcrypt. HOT 2
- YSI_Coding\y_timers\..\..\YSI_Core\y_core\y_scriptinit_impl.inc(434) : fatal error 111: user error: defined OnScriptInit HOT 1
- va_args stopped working after update HOT 6
- What does callbackfix.amx do? HOT 1
- (error) undefined symbol "Dialog_ShowPlayerNative HOT 2
- Error when using y_commands HOT 1
- Error when updating YSI HOT 2
- Long callback execution detected (hang or performance issue) or DDoS Attack HOT 1
- Issues with using y_iterator HOT 1
- y_inline_timers calling the timer function twice HOT 1
- AMX Size HOT 1
- Can't include y_races
- error complil HOT 1
- Y_Hooks not called with 3.10.11 Compiler and Open.MP HOT 2
- y_functional_funcs.inc(1154) : error 017: undefined symbol "j"
- bcrypt_delete File or function is not found since last YSI Update. HOT 4
- \pawno\include\YSI_Data\y_foreach\y_foreach_entry.inc(137) : fatal error 111: user error: Old <foreach.inc> found - delete it.
- Unable to compile with y_zonenames and y_races
- pawn.cc crashes when i use the last version of ysi includes
- helpp me YSI HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ysi-includes.