Error : proba.pwn(53) : error 033: array must be indexed (variable "wantedmodel")
#include <a_samp>
#include <zcmd>
#include <streamer>
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_LIME 0x10F441AA
#define COLOR_RED 0xFF0000AA
#define COLOR_BLUE 0x0000BBAA
#define COLOR_WHITE 0xFFFFFFAA
#define MAX_CP 100
new CP[MAX_CP];
new randompick;//should it be global ?
new wantedmodel[3];//is this right ?
forward Time();
forward VehPick();
new wantedcars[][][]=
{
{405, 10000, "Car"},
{522, 5000, "Bike"}
//model, price, name..
};
public VehPick()
{
new msg[128];
randompick = random(sizeof(wantedcars)); // should it remain new randompick = ... ?
//How can i let script know what model (wantedcars[randompick][0]) is picked ?
format(wantedmodel,sizeof(wantedmodel),"%d",wantedcars[randompick][0]);//i have no idea where im going with this.. :D
format(msg,sizeof(msg),"[WANTED CAR]: bla bla %s bla bla $%d!",wantedcars[randompick][2],wantedcars[randompick][1]); //we look for,we pay for..
SendClientMessageToAll(COLOR_WHITE,msg);
SetTimer("Time",15000,false);
}
public Time()
{
VehPick();
}
public OnGameModeInit()
{
AddPlayerClass(2,2261.3000000,-83.4000000,26.1000000,100.0000000,0,0,0,0,0,0);
VehPick();
AddStaticVehicleEx(410,405.2999900,2535.1001000,16.3000000,0.0000000,94,112,15); //Manana
AddStaticVehicleEx(405,2276.5000000,-84.5000000,26.4000000,76.0000000,32,32,15); //Sentinel
AddStaticVehicleEx(522,2261.3000000,-83.4000000,26.1000000,100.0000000,109,122,15); //NRG-500
CP[0] = CreateDynamicCP(2263.6418,-131.5671,27.4688,10.0,-1,-1,-1,50.0); // Final destination :D
return 1;
}
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
if(checkpointid == CP[0])
{
new Veh = GetPlayerVehicleID(playerid);
new VehModel = GetVehicleModel(Veh);
if(VehModel == wantedmodel) >>>> [Error line]
{
//give player money ..
}
}
return 1;
}
public OnPlayerEnterDynamicCP(playerid, checkpointid) { if(checkpointid == CP[0]) { new Veh = GetPlayerVehicleID(playerid); new VehModel = GetVehicleModel(Veh); if(VehModel == wantedmodel[0]) { //give player money .. } } return 1; }
Since you decleared wantedmodel as wantedmodel[3] it must be indexed like:
Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid) { if(checkpointid == CP[0]) { new Veh = GetPlayerVehicleID(playerid); new VehModel = GetVehicleModel(Veh); if(VehModel == wantedmodel[0]) { //give player money .. } } return 1; } |
#define MAX_CP 100
new CP[MAX_CP];
new randompick;//should it be global ?
new wantedmodel[3];//is this right ?
forward Time();
forward VehPick();
new wantedcars[][][]=
{
{405, 10000, "Car"},
{522, 5000, "Bike"}
//model, price, name..
};
public VehPick()
{
new msg[128];
randompick = random(sizeof(wantedcars)); // should it remain new randompick = ... ?
//How can i let script know what model (wantedcars[randompick][0]) is picked ?
format(wantedmodel,sizeof(wantedmodel),"%d",wantedcars[randompick][0]);//i have no idea where im going with this.. :D
format(msg,sizeof(msg),"[WANTED CAR]: bla bla %s bla bla $%d!",wantedcars[randompick][2],wantedcars[randompick][1]); //we look for,we pay for..
SendClientMessageToAll(COLOR_WHITE,msg);
SetTimer("Time",15000,false);
}
public Time()
{
VehPick();
}
public OnGameModeInit()
{
AddPlayerClass(2,2261.3000000,-83.4000000,26.1000000,100.0000000,0,0,0,0,0,0);
VehPick();
AddStaticVehicleEx(410,405.2999900,2535.1001000,16.3000000,0.0000000,94,112,15); //Manana
AddStaticVehicleEx(405,2276.5000000,-84.5000000,26.4000000,76.0000000,32,32,15); //Sentinel
AddStaticVehicleEx(522,2261.3000000,-83.4000000,26.1000000,100.0000000,109,122,15); //NRG-500
CP[0] = CreateDynamicCP(2263.6418,-131.5671,27.4688,10.0,-1,-1,-1,50.0); // Final destination :D
return 1;
}
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
if(checkpointid == CP[0])
{
new Veh = GetPlayerVehicleID(playerid);
//new VehModel = GetVehicleModel(Veh);
if(Veh == wantedmodel[0])
{
GivePlayerMoney(playerid,10);
SendClientMessage(playerid,-1,".");
}
}
return 1;
}
A variable holds an integer whatever digits it is that means you have to assign just new wantedmodel . Yes, you can make an array according to your needs.
And the " format " wantedmodel shouldn't be an string it is an integer so wantedmodel = wantedcars[Randompick][0]; |
format(wantedmodel,sizeof(wantedmodel),"%d",wantedcars[randompick][0]);
new wantedmodel[3];
new wantedmodel;
delete format line and put wantedmodel = wantedcars[Randompick][0];
|
error 006: must be assigned to an array
new wantedcars[][] |
if(Veh == wantedmodel)
if(Veh == strval(wantedmode))
try this:
Just two " [] "s Or return to your old code everything same the format and the wantedmodel[3] just change PHP код:
PHP код:
|
new wantedcars[][][]= { {405, 10000, "Car"}, {522, 5000, "Bike"} };
new wantedcars[][]= { {405, 10000, "Car"}, {522, 5000, "Bike"} };
Код HTML:
new wantedcars[][][]= { {405, 10000, "Car"}, {522, 5000, "Bike"} }; Код HTML:
new wantedcars[][]= { {405, 10000, "Car"}, {522, 5000, "Bike"} }; |