Problem with Iterators
#1

Hello, i try to use them for a jobid but i get this error

EDIT:
warning 203: symbol is never used: "Iter_Init@InJob"

use
Код:
new Iterator:InJob[16]<MAX_PLAYERS>;
Код:
if(PlayerInfo[playerid][pJob] > 0)
    {
    	new jobid = PlayerInfo[playerid][pJob];
    	Iter_Add(InJob[jobid], playerid);
    }
Can someone help me?
Reply
#2

Where is the error you mentioned?
Reply
#3

Quote:
Originally Posted by Eoussama
Посмотреть сообщение
Where is the error you mentioned?
#edited in first post.
Reply
#4

Your indexing is wack dude, seems to me you are overly thinking your problem with a dash of using the wrong kind of data usage.

You shouldn't need an iterator at all here it is pretty bad that people are giving you poor solutions to make your system design even worse.

Код:
enum JOBDATA
{
   e_CurrJob,
   e_Jobs[MAX_JOBS],
   bool:e_InJob[MAX_JOBS],
}

static g_JobData[MAX_PLAYERS][JOBDATA];
Then just reference the data by playerid example.

Код:
if(g_JobData[playerid][e_InJob][g_JobData[playerid][e_CurrJob]])
{

}
Reply
#5

Not sure, but Try this
Код:
new
	Iterator:OwnedVehicle[MAX_PLAYERS]<MAX_VEHICLES>;
Iter_Init(OwnedVehicle);
// Add vehicles to players here...
Iter_Add(OwnedVehicle[playerid], 42);
Iter_Add(OwnedVehicle[playerid], 43);
Iter_Add(OwnedVehicle[playerid], 44);
// Other code...
foreach (new vehicleid : OwnedVehicle[playerid])
{
	printf("Player %d owns vehicle %d", playerid, vehicleid).
}
Use Iter_Init(iterator_name) and see the results.
Source: https://sampforum.blast.hk/showthread.php?tid=570937

The first method is a little bit insufficient as it uses lots of slots,
try this method:
PHP код:
Iterator:OwnedVehicles<MAX_PLAYERSMAX_VEHICLES>;
Iterator:InJob<MAX_PLAYERS16>; 
Reply
#6

Quote:
Originally Posted by Pottus
Посмотреть сообщение
Your indexing is wack dude, seems to me you are overly thinking your problem with a dash of using the wrong kind of data usage.

You shouldn't need an iterator at all here.

Код:
enum JOBDATA
{
   e_CurrJob,
   e_Jobs[MAX_JOBS],
   bool:e_InJob[MAX_JOBS],
}

static g_JobData[MAX_PLAYERS][JOBDATA];
Then just reference the data by playerid example.

Код:
if(g_JobData[playerid][e_InJob][g_JobData[playerid][e_CurrJob]])
{

}
I need the Iterator to search every single player that was added for applied for ex: for Job 14 (trucker) when they lost their Trailer to put attach back. This is what I'm trying to do. I have a timer for this and i need to search every single player that was added in Iterator.
Reply
#7

You need to look here.

https://sampforum.blast.hk/showthread.php?tid=570937
Specifically Multi-Dimensional Iterators

But I still think you are overthinking and/or using some bad design choices.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)