/changeplate.
#1

I've created this command :
pawn Код:
CMD:changeplate(playerid, params[])
{
    new platenumber[124];
    if(sscanf(params, "i[24]", platenumber)) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /changeplate [platenumber]");
    if(!IsPlayerInAnyVehicle(playerid))
        return SendClientMessage(playerid, 0xFF9900AA, "You are not in a vehicle.");

    if(!dini_Exists("CarPlates.ini")) {
        dini_Create("CarPlates.ini");
    }
    new Str[128];
    new vehid = GetPlayerVehicleID(playerid);
    format(Str,128,"%d",vehid);
    dini_Set("CarPlates.ini", Str, platenumber);
    SetVehicleNumberPlate(GetPlayerVehicleID(playerid),platenumber);
    SetVehicleToRespawn(vehid);
    SendClientMessage(playerid, 0xFF9900AA, "License plate changed!");
    new Float:x, Float:y, Float:z, Float:a;
    GetVehicleZAngle(vehid,a);
    GetPlayerPos(playerid,x,y,z);
    SetVehiclePos(vehid,x,y,z);
    SetVehicleZAngle(vehid,a);
    PutPlayerInVehicle(playerid, vehid, 0);
    return 1;
}
Well, but ingame, how can I make that what I excatly write in the [platenumber] will be excatly on the plate ?
e.g : I write /changeplate 1337 then the car plate's will be 1337.
Reply
#2

Try this, not sure if it works

pawn Код:
CMD:changeplate(playerid, params[])
{
    new platenumber[124];
    if(sscanf(params, "i[24]", platenumber)) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /changeplate [platenumber]");
    if(!IsPlayerInAnyVehicle(playerid))
        return SendClientMessage(playerid, 0xFF9900AA, "You are not in a vehicle.");

    if(!dini_Exists("CarPlates.ini")) {
        dini_Create("CarPlates.ini");
    }
    new Str[128];
    new vehid = GetPlayerVehicleID(playerid);
    format(Str,128,"%d",vehid);
    dini_Set("CarPlates.ini", Str, platenumber);
    platenumber = strval(params);
    SetVehicleNumberPlate(GetPlayerVehicleID(playerid),platenumber);
    SetVehicleToRespawn(vehid);
    SendClientMessage(playerid, 0xFF9900AA, "License plate changed!");
    new Float:x, Float:y, Float:z, Float:a;
    GetVehicleZAngle(vehid,a);
    GetPlayerPos(playerid,x,y,z);
    SetVehiclePos(vehid,x,y,z);
    SetVehicleZAngle(vehid,a);
    PutPlayerInVehicle(playerid, vehid, 0);
    return 1;
}
Reply
#3

Quote:
Originally Posted by KingTurtle
Посмотреть сообщение
Try this, not sure if it works

pawn Код:
CMD:changeplate(playerid, params[])
{
    new platenumber[124];
    if(sscanf(params, "i[24]", platenumber)) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /changeplate [platenumber]");
    if(!IsPlayerInAnyVehicle(playerid))
        return SendClientMessage(playerid, 0xFF9900AA, "You are not in a vehicle.");

    if(!dini_Exists("CarPlates.ini")) {
        dini_Create("CarPlates.ini");
    }
    new Str[128];
    new vehid = GetPlayerVehicleID(playerid);
    format(Str,128,"%d",vehid);
    dini_Set("CarPlates.ini", Str, platenumber);
    platenumber = strval(params);
    SetVehicleNumberPlate(GetPlayerVehicleID(playerid),platenumber);
    SetVehicleToRespawn(vehid);
    SendClientMessage(playerid, 0xFF9900AA, "License plate changed!");
    new Float:x, Float:y, Float:z, Float:a;
    GetVehicleZAngle(vehid,a);
    GetPlayerPos(playerid,x,y,z);
    SetVehiclePos(vehid,x,y,z);
    SetVehicleZAngle(vehid,a);
    PutPlayerInVehicle(playerid, vehid, 0);
    return 1;
}
Quote:

error 033: array must be indexed (variable "platenumber")

Uhmmm...
Reply
#4

You could mabe use a input style dialog for that, yeah?
at the top
pawn Код:
#define PLATETEXTMENU 1234 //number can be anything not used by your scripts
in your command simply check if the player is in a vehicle & also if they are the driver.
pawn Код:
//changeplate
if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
     ShowPlayerDialog(playerid, PLATETEXTMENU , DIALOG_STYLE_INPUT, "Personal Numberplate", "Insert plate text", "Accept", "Cancel");//
//else don't do anything OR "Sendclientmsg - You must be driving a vehicle"
under "OnDialogResponse" for the "PLATETEXTMENU" simply add...
pawn Код:
if(response)
{
      new Float:vx, Float:vy, Float:vz, Float:vang;//
      GetVehiclePos(GetPlayerVehicleID(playerid), vx ,vy, vz);//
      GetVehicleZAngle(GetPlayerVehicleID(playerid), vang);//
      SetVehicleNumberPlate(GetPlayerVehicleID(playerid), inputtext);//
      SetVehicleToRespawn(GetPlayerVehicleID(playerid));//
      SetVehiclePos(GetPlayerVehicleID(playerid), vx, vy, vz);//
      PutPlayerInVehicle(playerid, GetPlayerVehicleID(playerid), 0);//
      SetVehicleZAngle(GetPlayerVehicleID(playerid), vang);//
//add your other needed code here....
}
doing it this way you can use stuff like "{000011}Darnell" which would insert your name on the license plate in black, other colours work too

Anyway Hope this helps
Reply
#5

That's a nice idea, but what other needed code, lol.
Reply
#6

Quote:
Originally Posted by Darnell
Посмотреть сообщение
That's a nice idea, but what other needed code, lol.
Oh is that Mb? because in your cmd it clearly looks like you were trying to save the input data for each user defined plate to some kind of ini file....like wtf?
Or was that just code in the cmd when you did the big copy paste? lulz...

BTW, its none of my bizzo but i suggest you remove "Coding for cash, PM me for information" if your not capable of doing so...
Reply
#7

Uhm, I just try to make a simple command to change the vehicles plate, ignore the dini part.
Reply
#8

Quote:
Originally Posted by Darnell
Посмотреть сообщение
Uhm, I just try to make a simple command to change the vehicles plate, ignore the dini part.
Ok umm Simple?, as you can see my way has a little less code and is extremely simple and very easy to implement and use in-game, but like i said it was just a suggestion...

PS: also i will try to ignore this
pawn Код:
if(!dini_Exists("CarPlates.ini")) {
        dini_Create("CarPlates.ini");
    }
    new Str[128];
    new vehid = GetPlayerVehicleID(playerid);
    format(Str,128,"%d",vehid);
    dini_Set("CarPlates.ini", Str, platenumber);
even though its very hard lulz
Reply
#9

I've did it, thanks Killaz .
Enjoy your rep point.
Reply
#10

Quote:
Originally Posted by Darnell
Посмотреть сообщение
Lol, well.
I still can't understand what to put in the dialog response so it'll change..As I've told, I'm a new scripter >.<.
Lolz, ya what!

look man everything i put there is basically copy paste-able, an we all started somewhere...

pawn Код:
#define PLATETEXTMENU 1234 //
in your command simply check if the player is in a vehicle & also if they are the driver.
pawn Код:
//changeplate command
if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
    ShowPlayerDialog(playerid, PLATETEXTMENU , DIALOG_STYLE_INPUT, "Personal Numberplate", "Insert plate text", "Accept", "Cancel");//
//else don't do anything OR "Sendclientmsg - You must be driving a vehicle"
under "OnDialogResponse" simply add...
pawn Код:
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == PLATETEXTMENU)
    {
        if(response)
        {
            new Float:vx, Float:vy, Float:vz, Float:vang;//
            GetVehiclePos(GetPlayerVehicleID(playerid), vx ,vy, vz);//
            GetVehicleZAngle(GetPlayerVehicleID(playerid), vang);//
            SetVehicleNumberPlate(GetPlayerVehicleID(playerid), inputtext);//
            SetVehicleToRespawn(GetPlayerVehicleID(playerid));//
            SetVehiclePos(GetPlayerVehicleID(playerid), vx, vy, vz);//
            PutPlayerInVehicle(playerid, GetPlayerVehicleID(playerid), 0);//
            SetVehicleZAngle(GetPlayerVehicleID(playerid), vang);//
        }
        else//they select cancel
        {
            return 1;//do nothing...
        }
    }
    return 0;
Goodluck!
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)