[HELP] Sub Array
#1

How to make a sub array? I need to attach 2 things on one array, i need to attach the Name and CreateVehicle thing, so that i can use either
Код:
Array[playername]
if (GetPlayerName(playerid) == Array[Paranoja] {
true
}
or
Array[playername] = CreateVehicle(content);
Код:
if(GetPlayerVehicleID(playerid) = Array[Paranoja] {
So basicaly i want to get the content from the brackets of the array and also the thing which is attached to it. Thank you for your reply.
Reply
#2

Are you trying to make it like that only you can enter a car? if so, you just use 'strcmp'

pawn Код:
new name[24];
GetPlayerName(playerid, name, 24);
if(!strcmp(name, "paranoja", true))
{
  CreateVehicle(...);
} else return SendClientMessage(playerid, 0xFF0000AA, "I will only obey master Paranoja");
like that : >

That is all that I can figure out from your post, if this is wrong, please reply
Reply
#3

I also need it for DestroyVehicle(Array[playername]); since the vehicle blows up, i need it for many more uses, i just need to have 1 array and 2 functions, meanings or smth attached to it.
P.S. It's not going to be only Paranoja the name.. It will be many random names. There's abit of my code:
Код:
	new query1[256];
	new usercar[11][128];
	new usercaruniqueid;
	new usercarowner;
	new usercarmodelid;
	new Float:usercarspawnX;
	new Float:usercarspawnY;
	new Float:usercarspawnZ;
	new Float:usercarangle;
	new usercarcolor1, usercarcolor2;
	new usercartune;
	new usercarlocked;
	new usercarid[MAX_PLAYER_NAME];
	format(query1, sizeof(query1), "SELECT id,owner,modelid,spawn_x,spawn_y,spawn_z,angle,color1,color2,tune,locked FROM `ucars`");
	samp_mysql_query(query1);
	samp_mysql_store_result();
	while(samp_mysql_fetch_row(query1)) {
		split(query1, usercar, '|');
		usercaruniqueid = strval(usercar[0]);
		usercarowner = strval(usercar[1]);
		usercarmodelid = strval(usercar[2]);
		usercarspawnX = floatstr(usercar[3]);
		usercarspawnY = floatstr(usercar[4]);
		usercarspawnZ = floatstr(usercar[5]);
		usercarangle = floatstr(usercar[6]);
		usercarcolor1 = strval(usercar[7]);
		usercarcolor2 = strval(usercar[8]);
		usercartune = strval(usercar[9]);
		usercarlocked = strval(usercar[10]);
		usercarid[usercarowner] = CreateVehicle(usercarmodelid,usercarspawnX,usercarspawnY,usercarspawnZ,usercarangle,usercarcolor1,usercarcolor2,-1);
		for (players=0;players<MAX_PLAYERS; players++) {
			SetVehicleParamsForPlayer(usercarid[usercarowner],players,0,1);
		}
	}
Mysql Entry: id: 1, owner: paranoja, modelid: 540, spawn_x: xlocation, spawn_y: ylocation, spawn_z: zlocation, angle: angle, color1: 1, color2: 1
As you can see on the end of the script, the car must lock, but it doesn't.
Reply
#4

usercarowner is a name and not an ID so that isnt going to work. : >
Reply
#5

Ye exactly, so i need some way, to have createvehicle and the ownername of the vehicle together.
Reply
#6

UP, sorry for double post, but i realy need this thing.. I can't move on without it. Lets forget than 2 things on one array and tell me how to do an unique array for each player. So that i can check which car belongs to which player.
Reply
#7

Enumerations. They are really useful here.
Reply
#8

Thank you very much, i quess that is what i were looking for, but now i have another question, how to assign the array on player's name? I want to load my cars on GameModeInit, so that every single car would be loaded in server, not only when the player connects to the server, and his car spawns than...

Why it gives me an error:
Код:
C:\Kita\Deivido\Samp\Naujas\gamemodes\ruined.pwn(371) : error 033: array must be indexed (variable "nickname")
Code:
Код:
	new nickname[MAX_PLAYER_NAME];
	GetPlayerName(playerid, nickname, MAX_PLAYER_NAME);
	if (playercar[car_owner] == nickname) {
		SetVehicleParamsForPlayer(playercar[car_id],playerid,1,0);
	} else {
		for (players=0;players<MAX_PLAYERS; players++) {
			SetVehicleParamsForPlayer(playercar[car_id],players,0,1);
		}
	}
Reply
#9

INTERNET PROBLEMS (DOUBLE POST) DELETE
Reply
#10

which line is 371?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)