Array Error
#1

Код HTML:
F:\CNR - RP\gamemodes\arcnr2p.pwn(2136) : error 006: must be assigned to an array
Код HTML:
    for(new v=0; v<MAX_VEHICLES; v++)
	{
	    VehicleInfo[v][bought] = pname;  << this line
	    VehicleInfo[v][stolen] =0;
	    VehicleInfo[v][bombed] =0;
	}
Reply
#2

pawn Код:
strcpy(VehicleInfo[v][bought], pname, MAX_PLAYER_NAME);
pawn Код:
#define strcpy(%0,%1) strcat((%0[0] = '\0', %0), %1)
Reply
#3

where i can put that?
Reply
#4

Add the macro somewhere in your script and replace:
pawn Код:
VehicleInfo[v][bought] = pname;
with this:
pawn Код:
strcpy(VehicleInfo[v][bought], pname, MAX_PLAYER_NAME);
Reply
#5

thank you so much sir!
Reply
#6

Код HTML:
F:\CNR - RP\gamemodes\arcnr2p.pwn(2136) : error 001: expected token: ")", but found "["
F:\CNR - RP\gamemodes\arcnr2p.pwn(2136) : warning 215: expression has no effect
F:\CNR - RP\gamemodes\arcnr2p.pwn(2136) : error 001: expected token: ";", but found "]"
F:\CNR - RP\gamemodes\arcnr2p.pwn(2136) : error 029: invalid expression, assumed zero
F:\CNR - RP\gamemodes\arcnr2p.pwn(2136) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Whats the problem?
Reply
#7

In the enum used for VehicleInfo array, make "bought" an array with size of MAX_PLAYER_NAME:
pawn Код:
// in the enum:
bought[MAX_PLAYER_NAME] // add a comma if it's not last.
Reply
#8

Thanks !
Reply
#9

Код HTML:
F:\CNR - RP\gamemodes\arcnr2p.pwn(3138) : error 033: array must be indexed (variable "pname")
Код HTML:
public OnVehicleDeath(vehicleid, killerid)
{
    for(new i = 0; i < MAX_PLAYERS; i++){
		new pname[24];
		GetPlayerName(i,pname,sizeof(pname));
	if(VehicleInfo[vehicleid][bought] == pname) << this line?
	{
	    SendClientMessage(VehicleInfo[vehicleid][bought],COLOR_ERROR,"The car your purchased from Otto's Cars has been destroyed.");
		DestroyVehicle(vehicleid);
	}
	VehicleInfo[vehicleid][bought] = 999;
	VehicleInfo[vehicleid][stolen] =0;
	VehicleInfo[vehicleid][bombed] =0;
	}
	return 1;
}
Reply
#10

You cannot use "bought" for both owner's name and price. Use another name for the price and use strcmp to compare strings:
pawn Код:
if (!strcmp(VehicleInfo[vehicleid][bought], pname, true, MAX_PLAYER_NAME))
and because strcmp returns 0 if one of them is NULL you can prevent it by doing:
pawn Код:
if (!isnull(VehicleInfo[vehicleid][bought]) && !strcmp(VehicleInfo[vehicleid][bought], pname, true, MAX_PLAYER_NAME))
and as I said before, use another name for the price here:
pawn Код:
VehicleInfo[vehicleid][bought] = 999;
or whatever it is anyways.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)