Error: Argument type Mismatch
#1

Hi. I've been working on a Vehicle system. I'm currently working on the Saving and Loading of Vehicles.

I'm getting this Error:

Код:
Line 347: error 035: argument type mismatch (argument 9)
This is the Code:

Код:
YCMD:createvehicle(playerid, params[], help) 
{
	if(help) return SendClientMessage(playerid, -1, "Allows to create a dynamic vehicle.");

	new vehModel, vehColor1, vehColor2, vehRespawnTime; 

	if(sscanf(params, "iiii", vehModel, vehColor1, vehColor2, vehRespawnTime))
		return SendClientMessage(playerid, -1, "USAGE: /createvehicle [Vehicle Model] [Color 1] [Color 2] [Respawn Time]"); 

	new Float:x, Float:y, Float:z, Float:angle; 
	new strPlayerName[MAX_PLAYER_NAME];
	new vehicleid;
	GetPlayerPos(playerid, x, y, z);
	GetPlayerFacingAngle(playerid, angle); 
	GetPlayerName(playerid, strPlayerName, MAX_PLAYER_NAME); 
	vehicleid = CreateVehicleEx(vehModel, x, y, z, angle, vehColor1, vehColor2, vehRespawnTime, strPlayerName, 160000, true); //line 347. Argument 9 is the strPlayerName(Owner name in the original function)

	PutPlayerInVehicle(playerid, vehicleid, 0); 

	return 1;
}
CreateVehicleEx Function:

Код:
stock CreateVehicleEx(vehicleModel, Float:vxSpawn, Float:vySpawn, Float:vzSpawn, Float:vangleSpawn, vehicleColor1, vehicleColor2, vehicleRespawn, vehicleOwner, vehiclePrice, bool:vehicleBuyable) {
	new vehicleid = GetFreeVehicleSlot();
	
	VehicleInfo[vehicleid][vModel] 		= vehicleModel;
	VehicleInfo[vehicleid][xSpawn]  	= vxSpawn;
    VehicleInfo[vehicleid][ySpawn] 		= vySpawn;
    VehicleInfo[vehicleid][zSpawn] 		= vzSpawn;
    VehicleInfo[vehicleid][angleSpawn]  = vangleSpawn;
    VehicleInfo[vehicleid][vCol1] 		= vehicleColor1;
    VehicleInfo[vehicleid][vCol2] 		= vehicleColor2;
    VehicleInfo[vehicleid][vRespawn] 	= vehicleRespawn,
    VehicleInfo[vehicleid][vOwner] 		= vehicleOwner;
    VehicleInfo[vehicleid][vPrice] 		= vehiclePrice;
	VehicleInfo[vehicleid][vBuyable] 	= vehicleBuyable;
    
    VehicleInfo[vehicleid][vID] 		= CreateVehicle(vehicleModel, vxSpawn, vySpawn, vzSpawn, vangleSpawn, vehicleColor1, vehicleColor2, vehicleRespawn);
    
    vCreated[vehicleid] = true;
    
    return vehicleid;
}
I'm still testing the Loading and Saving. So I need this command to proceed.

Any help would be really great. Thanks.
Reply
#2

Try this:
PHP код:
CreateVehicleEx(vehicleModelFloat:vxSpawnFloat:vySpawnFloat:vzSpawnFloat:vangleSpawnvehicleColor1vehicleColor2vehicleRespawnvehicleOwner[MAX_PLAYER_NAME], vehiclePricebool:vehicleBuyable)
{
    new 
vehicleid GetFreeVehicleSlot();
    
    
VehicleInfo[vehicleid][vModel]         = vehicleModel;
    
VehicleInfo[vehicleid][xSpawn]      = vxSpawn;
    
VehicleInfo[vehicleid][ySpawn]         = vySpawn;
    
VehicleInfo[vehicleid][zSpawn]         = vzSpawn;
    
VehicleInfo[vehicleid][angleSpawn]  = vangleSpawn;
    
VehicleInfo[vehicleid][vCol1]         = vehicleColor1;
    
VehicleInfo[vehicleid][vCol2]         = vehicleColor2;
    
VehicleInfo[vehicleid][vRespawn]     = vehicleRespawn,
    
VehicleInfo[vehicleid][vOwner]         = vehicleOwner;
    
VehicleInfo[vehicleid][vPrice]         = vehiclePrice;
    
VehicleInfo[vehicleid][vBuyable]     = vehicleBuyable;
    
    
VehicleInfo[vehicleid][vID]         = CreateVehicle(vehicleModelvxSpawnvySpawnvzSpawnvangleSpawnvehicleColor1vehicleColor2vehicleRespawn);
    
    
vCreated[vehicleid] = true;
    
    return 
vehicleid;

But I'm not sure about
Код:
VehicleInfo[vehicleid][vOwner] 		= vehicleOwner;
If you have any errors about this, replace by this
PHP код:
format(VehicleInfo[vehicleid][vOwner], MAX_PLAYER_NAME,"%s",vehicleOwner); 
Reply
#3

Where is line 347?
Reply
#4

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
Try this:
PHP код:
CreateVehicleEx(vehicleModelFloat:vxSpawnFloat:vySpawnFloat:vzSpawnFloat:vangleSpawnvehicleColor1vehicleColor2vehicleRespawnvehicleOwner[MAX_PLAYER_NAME], vehiclePricebool:vehicleBuyable)
{
    new 
vehicleid GetFreeVehicleSlot();
    
    
VehicleInfo[vehicleid][vModel]         = vehicleModel;
    
VehicleInfo[vehicleid][xSpawn]      = vxSpawn;
    
VehicleInfo[vehicleid][ySpawn]         = vySpawn;
    
VehicleInfo[vehicleid][zSpawn]         = vzSpawn;
    
VehicleInfo[vehicleid][angleSpawn]  = vangleSpawn;
    
VehicleInfo[vehicleid][vCol1]         = vehicleColor1;
    
VehicleInfo[vehicleid][vCol2]         = vehicleColor2;
    
VehicleInfo[vehicleid][vRespawn]     = vehicleRespawn,
    
VehicleInfo[vehicleid][vOwner]         = vehicleOwner;
    
VehicleInfo[vehicleid][vPrice]         = vehiclePrice;
    
VehicleInfo[vehicleid][vBuyable]     = vehicleBuyable;
    
    
VehicleInfo[vehicleid][vID]         = CreateVehicle(vehicleModelvxSpawnvySpawnvzSpawnvangleSpawnvehicleColor1vehicleColor2vehicleRespawn);
    
    
vCreated[vehicleid] = true;
    
    return 
vehicleid;

But I'm not sure about
Код:
VehicleInfo[vehicleid][vOwner] 		= vehicleOwner;
If you have any errors about this, replace by this
PHP код:
format(VehicleInfo[vehicleid][vOwner], MAX_PLAYER_NAME,"%s",vehicleOwner); 
It didn't work. It gives me Array sizes do not match error.

Quote:
Originally Posted by Arturo226
Посмотреть сообщение
Where is line 347?
It's in the createvehicle command. I have added a comment.
Reply
#5

Код:
stock CreateVehicleEx(vehicleModel, Float:vxSpawn, Float:vySpawn, Float:vzSpawn, Float:vangleSpawn, vehicleColor1, vehicleColor2, vehicleRespawn, vehicleOwner[], vehiclePrice, bool:vehicleBuyable)
Reply
#6

Quote:
Originally Posted by LatinZ
Посмотреть сообщение
Код:
stock CreateVehicleEx(vehicleModel, Float:vxSpawn, Float:vySpawn, Float:vzSpawn, Float:vangleSpawn, vehicleColor1, vehicleColor2, vehicleRespawn, vehicleOwner[], vehiclePrice, bool:vehicleBuyable)
Nope, It gives me the Array sizes do not match error. :/
Reply
#7

And this one?
PHP код:
CreateVehicleEx(vehicleModelFloat:vxSpawnFloat:vySpawnFloat:vzSpawnFloat:vangleSpawnvehicleColor1vehicleColor2vehicleRespawnvehicleOwner[24], vehiclePricebool:vehicleBuyable
Reply
#8

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
And this one?
PHP код:
CreateVehicleEx(vehicleModelFloat:vxSpawnFloat:vySpawnFloat:vzSpawnFloat:vangleSpawnvehicleColor1vehicleColor2vehicleRespawnvehicleOwner[24], vehiclePricebool:vehicleBuyable
Nope. :/

It still gives me the Array size do not match error. I've tried that earlier. Also tried this.

PHP код:
CreateVehicleEx(vehicleModelFloat:vxSpawnFloat:vySpawnFloat:vzSpawnFloat:vangleSpawnvehicleColor1vehicleColor2vehicleRespawnvehicleOwner[MAX_PLAYER_NAME], vehiclePricebool:vehicleBuyable
Both of them didn't work.
Reply
#9

Keep it as:
pawn Код:
stock CreateVehicleEx(vehicleModel, Float:vxSpawn, Float:vySpawn, Float:vzSpawn, Float:vangleSpawn, vehicleColor1, vehicleColor2, vehicleRespawn, vehicleOwner[], vehiclePrice, bool:vehicleBuyable)
Never assign directly to copy strings like this:
pawn Код:
VehicleInfo[vehicleid][vOwner]      = vehicleOwner;
that is not the correct way. You can use strcpy:
pawn Код:
#if !defined strcpy
    #define strcpy(%0,%1) strcat((%0[0] = EOS, %0), %1)
#endif
and usage:
pawn Код:
strcpy(destination, source, size);
size is optional but you have to specify it if it enum-array. So that would be:
pawn Код:
strcpy(VehicleInfo[vehicleid][vOwner], vehicleOwner, MAX_PLAYER_NAME);
Last, add a size to "vehicleOwner" in the enum:
pawn Код:
vehicleOwner[MAX_PLAYER_NAME],
Doing the all the above makes it compile.
Reply
#10

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Keep it as:
pawn Код:
stock CreateVehicleEx(vehicleModel, Float:vxSpawn, Float:vySpawn, Float:vzSpawn, Float:vangleSpawn, vehicleColor1, vehicleColor2, vehicleRespawn, vehicleOwner[], vehiclePrice, bool:vehicleBuyable)
Never assign directly to copy strings like this:
pawn Код:
VehicleInfo[vehicleid][vOwner]      = vehicleOwner;
that is not the correct way. You can use strcpy:
pawn Код:
#if !defined strcpy
    #define strcpy(%0,%1) strcat((%0[0] = EOS, %0), %1)
#endif
and usage:
pawn Код:
strcpy(destination, source, size);
size is optional but you have to specify it if it enum-array. So that would be:
pawn Код:
strcpy(VehicleInfo[vehicleid][vOwner], vehicleOwner, MAX_PLAYER_NAME);
Last, add a size to "vehicleOwner" in the enum:
pawn Код:
vehicleOwner[MAX_PLAYER_NAME],
Doing the all the above makes it compile.
Thanks a lot.. It worked..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)