Strange problem with an array
#1

Код:
CMD:joins(playerid, params[])
{
	if(shooton == false) return SendClientMessage(playerid, COLOR_RED, "*** Evento disattivato!");
//	if(pshooter[playerid] >=  0) return SendClientMessage(playerid, COLOR_RED, "*** Sei giа nell'evento!");
	if(shootstart == true) return SendClientMessage(playerid, COLOR_RED, "*** L'evento и giа iniziato!");
	if(contaveh >= 20) return SendClientMessage(playerid, COLOR_RED, "*** Non ci sono piщ posti all'evento!");
	new str[100];
	for(new i = 0; i <= contaveh; i++)
	{
	    printf("xd");
 		if(vehshoot[i] == -1)
		{
 			vehshoot[i] = CreateVehicle(411, postiveh[i][0], postiveh[i][1], postiveh[i][2], postiveh[i][3], 9, 74, -1);
			SettaVarS(playerid, vehshoot[i], 1);
			pshooter[playerid] = i;
			contaveh++;
		 	break;
		}
	}
	printf("\n%d %d  b", contaveh, pshooter[playerid]);
	format(str, sizeof(str), "*** Posti disponibili all'evento: %d/20", 20-contaveh);
	SendClientMessageToAll(COLOR_GREEN, str);
	return 1;
}

CMD:leaves(playerid, params[])
{
	if(shooton == false) return SendClientMessage(playerid, COLOR_RED, "*** Evento disattivato!");
	if(pshooter[playerid] == -1) return SendClientMessage(playerid, COLOR_RED, "*** Non fai parte dell'evento!");
	new str[100], nome[24];
	GetPlayerName(playerid, nome, 24);
	SettaVarS(playerid, vehshoot[pshooter[playerid]], 0);
	format(str, sizeof(str), "*** %s и uscito dall'evento car-shooter!", nome);
	SendClientMessageToAll(COLOR_RED, str);
	return 1;
}

-------------------------------------------------

stock SettaVarS(playerid, vehicleid, var)
{
	if(var)
	{
		SetVehicleVirtualWorld(vehicleid, 8378);
		SetPlayerVirtualWorld(playerid, 8378);
		PutPlayerInVehicle(playerid, vehicleid, 0);
		TogglePlayerControllable(playerid, 0);
		SettaObjectS(playerid, vehicleid);
		printf("\n%d %d  a", contaveh, pshooter[playerid]);
	}
	else if(!var)
	{
        DestroyVehicle(vehicleid);
        vehicleid = -1;
        pshooter[playerid] = -1;
        contaveh--;
        TogglePlayerControllable(playerid, 1);
		SetPlayerVirtualWorld(playerid, 0);
		SpawnPlayer(playerid);
		printf("\n%d %d  c", contaveh, pshooter[playerid]);
	}
	
}
When i do /leaves command and rejoin for any reason vehicleid doesn't set to -1, then when i call the cicle for to check if any vehshoot is = -1 doesn't find nothing, but when i call the function SettaVarS with vehshoot[pshooter[playerid]] for /leave it should be set to -1.

Is there any logic error that i can't find or what
Reply
#2

Up!!!!!!!!
Код HTML:

Reply
#3

Write the function header like this:

PHP код:
stock SettaVarS(playerid, &vehicleid, var) 
That should solve your problem
Reply
#4

it works! thanks a lot
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)