Doesn't get ModelID -
[XST]O_x - 18.05.2010
Hello there,
I tried to make a /spawn command,which will spawn you a vehicle.
Well it does spawn you a vehicle,it just doesn't send me the correct Model ID of the vehicle that spawned.
Code:
pawn Код:
if(strcmp( cmd, "/spawn", true ) == 0 )
{
if(!cmdtext[6])return SendClientMessage(playerid, COLOR_PURPLE, "USAGE: /Spawn [MODELID]");
new Float:X, Float:Y, Float:Z;
new tmp[256];
new NameForSpawned;
new Float:a;
tmp = strtok( cmdtext, idx );
GetPlayerPos( playerid, X, Y, Z );
GetPlayerFacingAngle(playerid,a);
CreateVehicle( strval(tmp), X+2, Y+2, Z, a+90, -1, -1, -1 );
NameForSpawned = GetVehicleModel(strval(tmp));
new msg[256];
format(msg,256,"Created vehicle: %d",NameForSpawned);
SendClientMessage(playerid,COLOR_PURPLE,msg);
return 1;
}
It always sends : "
Created vehicle: 0"
Well please help me if possible.
Thanks in advance.
Re: Doesn't get ModelID -
[XST]O_x - 19.05.2010
bumped D:
Re: Doesn't get ModelID -
Calgon - 19.05.2010
It's stupid that you create strings with 256 cells, when not even 100 will even get used.
pawn Код:
if(strcmp( cmd, "/spawn", true ) == 0 )
{
if(!cmdtext[6]) return SendClientMessage(playerid, COLOR_PURPLE, "USAGE: /Spawn [MODELID]");
new
tmp[128],
msg[21],
Float:a,
Float:X,
Float:Y,
Float:Z,
idx,
model;
model = strval( strtok( cmdtext, idx ) );
GetPlayerPos( playerid, X, Y, Z );
GetPlayerFacingAngle(playerid,a);
CreateVehicle( model, X+2, Y+2, Z, a+90, -1, -1, -1 );
format(msg,21,"Created vehicle model: %d", model);
SendClientMessage(playerid,COLOR_PURPLE,msg);
return 1;
}
Re: Doesn't get ModelID -
[XST]O_x - 19.05.2010
Sorry,my bad.
Thanks!
Re: Doesn't get ModelID -
Rac3r - 19.05.2010
Quote:
Originally Posted by Freddo [BINMAN
]
It's stupid that you create strings with 256 cells, when not even 100 will even get used.
|
Not really, in a flash the string will be set and you won't notice the unused cells.
What's stupid is formatting a string with not enough cells.
Код:
format(msg,21,"Created vehicle model: %d", model);
21 cells is 'Created vehicle model', so the vehicle model would never be sent in the client message. Now that's stupid.
Re: Doesn't get ModelID -
Calgon - 19.05.2010
Quote:
Originally Posted by Rac3r
Quote:
Originally Posted by Freddo [BINMAN
]
It's stupid that you create strings with 256 cells, when not even 100 will even get used.
|
Not really, in a flash the string will be set and you won't notice the unused cells.
What's stupid is formatting a string with not enough cells.
Код:
format(msg,21,"Created vehicle model: %d", model);
21 cells is 'Created vehicle model', so the vehicle model would never be sent in the client message. Now that's stupid. 
|
So just add more, I missed out a few as I miscalculated. Do you not understand the concept of wasting cells and how it increases the size of your AMX? No? I assumed not.
Re: Doesn't get ModelID -
[XST]O_x - 19.05.2010
It doesn't matter now guys,I changed it to 38 and it's working great