Doesn't get ModelID
#1

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.
Reply
#2

bumped D:
Reply
#3

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;
    }
Reply
#4

Sorry,my bad.
Thanks!
Reply
#5

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.
Reply
#6

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.
Reply
#7

It doesn't matter now guys,I changed it to 38 and it's working great
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)