Car Units
#1

Hey there,

I'm fairly new to scripting. I know a bit but not a huge deal.

was wondering if its possible some hoe to have it so I can use a command to set a name for a car.

Eg: I get in Vehicle A: a Police Ranger and type /setplate <What I want it to be>

It Saves, Then when Someone gets in that car it says what I put. I know it would require something under

OnPlayerEnterVehicle.
Reply
#2

i think thats impossible i know there is roleplay server's with car plates but it isnt with a command
This forum requires that you wait 120 seconds between posts. Please try again in 51 seconds.
OH CUMON!!!!
Reply
#3

Car Plates are deleted since 0.3 and what do u mean with /setplate lol
Reply
#4

Like, It writes the carid to a .txt file or something idk use dini and then when you eneter the vehicle it displays the defined car number. Eg if I defined a police ranger as unit 581. When I get in it will say Unit: 581.

The /setplate was an example of a command that would be used to do this.
Reply
#5

Impossible
Reply
#6

https://sampwiki.blast.hk/wiki/Attach3DTextLabelToVehicle

you can use 3d labels for car plate no in 0.3
Reply
#7

Guys, this is absolutely possible, he just wants to show the name on enter, not change the number plate.
Create a big array like this:

new CarNames[MAX_VEHICLES][24];

Ok, this eats a lot of ram, ~200kb, but this should be no big problem.
Then add a command like this (untested):

pawn Код:
//Usage: /setplate <new_name>
if(strcmp("/setplate", cmdtext, true, 9) == 0)
{
    if(!IsPlayerInAnyVehicle(playerid)) return 1;
    strmid(CarNames[GetPlayerVehicleID(playerid)], cmdtext, 10, strlen(cmdtext));
    new text[64];    
    format(text, 64, "You changed the vehicle's name to %s.", CarNames[GetPlayerVehicleID(playerid)]);
    SendClientMessage(playerid, 0xAAAA33AA, text);
    return 1;
}

//To show it on vehicle enter add this to your OnPlayerEnterVehicle, as you already mentioned
if(strlen(CarNames[vehicleid])
{
    new text[64];    
    format(text, 64, "You entered the vehicle: %s.", CarNames[vehicleid]);
    SendClientMessage(playerid, 0xAAAA33AA, text);
}
//Change all strings to whatever you want
Saving that all would be harder, because most ini includes do not support 2000 entries in a file. You would need a car saver system that creates a file for each car and spawns them from that file, so that there are no problems with changing vehicle ids.
Reply
#8

Fwrite supports 2000 entries or?, otherwise use mysql
Reply
#9

Is it possible to save it so you dont have to do it every time the server restarts??
Reply
#10

Bump. Been over 24 Hours
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)