PDA

View Full Version : License plate (save help)


Antonio [G-RP]
31/07/2009, 03:52 AM
Okay. I have a code to change car plate, but I want to add to it

1. To save the plate to the cars files

2. The player changing the plate must own the car.

Heres the code....


if(strcmp(cmd,"/carplate",true)==0)
{
new vehicleid = GetPlayerVehicleID(playerid);

if(PlayerInfo[playerid][pDonation] <= 1)
{
SendClientMessage(playerid,COLOR_RED,"You must have donated to be able to change your personal license plate");
return 1;
}

if(GetPlayerState(playerid) != 2)
{
SendClientMessage(playerid,COLOR_YELLOW,"You must be the driver of a Vehicle to change the personal license plate");
return 1;
}

/*if(IsPlayerInVehicleWithNoPlates(playerid,vehicle id))
{
SendClientMessage(playerid,COLOR_YELLOW,"Your vehicle does not have a personal license plate");
return 1;
}*/

tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid,COLOR_YELLOW,"USAGE: /carplate [car plate text]");
SendClientMessage(playerid,COLOR_YELLOW,"NOTE: To put one or more Spaces, you must put an _ (Underslash)");
return 1;
}

if(strlen(tmp)<0 || strlen(tmp)>8)
{
SendClientMessage(playerid,COLOR_YELLOW,"Number Plates can only be 1-8 characters long!");
return 1;
}
else
{
GetVehiclePos(vehicleid,VPos[0],VPos[1],VPos[2]);
GetVehicleZAngle(vehicleid,VPos[3]);
SetVehicleNumberPlate(vehicleid,tmp);
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid,false);
SetVehicleToRespawn(vehicleid);
gPlayerVehicle[playerid] = vehicleid;
SetTimerEx("VehicleTimer",700,0,"i",playerid);
SendClientMessage(playerid,COLOR_YELLOW,"There will be a very short delay while your personal license plate is set.");
return 1;
}
}

Adrik
31/07/2009, 10:59 PM
Please help.

zombie13333
01/08/2009, 12:42 AM
I recommend either:

dudb, or dini

Read some examples off there, or filterscripts that save things like positions.
It shouldn't be too hard.

Antonio [G-RP]
03/08/2009, 04:11 AM
Is there a way not to do that? (bump)

I mean like

GetPlayerVehicleID
and
the command to get the players car they own's ID

then to match (if the not the same, not allow plate switch)

Shadow_
03/12/2010, 08:37 PM
well, you need to give your vehicle system if you want somebody to create it for you .. as they need the callbacks ect, to know how to get the players vehicle ID but you gotta save it somewhere .. probably add it to the enum that your vehicle system is made on .. which as im sure it is some godfather edit.

Fresh-Gta
03/12/2010, 08:59 PM
this will create .ini file in your scriptfiles/license folder
hope you understand basics sorry i got real tired of scripting today try to write load function yourself
tips..
write it ongamemodeinit
and use
dini_int (for integer)
dini_get (for text)
if(strcmp(cmd,"/carplate",true)==0)
{
new vehicleid = GetPlayerVehicleID(playerid);

if(PlayerInfo[playerid][pDonation] <= 1)
{
SendClientMessage(playerid,COLOR_RED,"You must have donated to be able to change your personal license plate");
return 1;
}

if(GetPlayerState(playerid) != 2)
{
SendClientMessage(playerid,COLOR_YELLOW,"You must be the driver of a Vehicle to change the personal license plate");
return 1;
}

/*if(IsPlayerInVehicleWithNoPlates(playerid,vehicle id))
{
SendClientMessage(playerid,COLOR_YELLOW,"Your vehicle does not have a personal license plate");
return 1;
}*/

tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid,COLOR_YELLOW,"USAGE: /carplate [car plate text]");
SendClientMessage(playerid,COLOR_YELLOW,"NOTE: To put one or more Spaces, you must put an _ (Underslash)");
return 1;
}

if(strlen(tmp)<0 || strlen(tmp)>8)
{
SendClientMessage(playerid,COLOR_YELLOW,"Number Plates can only be 1-8 characters long!");
return 1;
}
else
{
new Filename[64];
format(Filename, sizeof(Filename), "license/%i.ini", vehicleid);
if(dini_Exists(Filename)) return SendClientMessage(playerid, COLOR_RED, "Your car already has a plate");
dini_Create(Filename);
dini_Set(Filename, "VehicleNumberPlate", tmp);
dini_IntSet(Filename, "Teh", 1);
GetVehiclePos(vehicleid,VPos[0],VPos[1],VPos[2]);
GetVehicleZAngle(vehicleid,VPos[3]);
SetVehicleNumberPlate(vehicleid,tmp);
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid,false);
SetVehicleToRespawn(vehicleid);
gPlayerVehicle[playerid] = vehicleid;
SetTimerEx("VehicleTimer",700,0,"i",playerid);
SendClientMessage(playerid,COLOR_YELLOW,"There will be a very short delay while your personal license plate is set.");
return 1;
}
}

GoldenM4
23/12/2010, 04:07 PM
you need to have a register system for this that has donation feature

propilot
23/12/2010, 04:08 PM
you need to have a register system for this that has donation feature

No you, dont.
You can make it save in a .txt file or something and a rcon admin canmake like /makevip [level] ( 0/1/2/3/4 )

Jack_Loreva
08/08/2012, 06:56 PM
Guys, I tried this Script but I got some Errors

C:\Documents and Settings\Abdo\Bureau\American's Dream RP\gamemodes\ADRP.pwn(86269) : error 017: undefined symbol "pDonation"
C:\Documents and Settings\Abdo\Bureau\American's Dream RP\gamemodes\ADRP.pwn(86287) : error 017: undefined symbol "tmp"
C:\Documents and Settings\Abdo\Bureau\American's Dream RP\gamemodes\ADRP.pwn(86287) : error 017: undefined symbol "strtok"
C:\Documents and Settings\Abdo\Bureau\American's Dream RP\gamemodes\ADRP.pwn(86288) : error 017: undefined symbol "tmp"
C:\Documents and Settings\Abdo\Bureau\American's Dream RP\gamemodes\ADRP.pwn(86295) : error 017: undefined symbol "tmp"
C:\Documents and Settings\Abdo\Bureau\American's Dream RP\gamemodes\ADRP.pwn(86306) : error 017: undefined symbol "tmp"
C:\Documents and Settings\Abdo\Bureau\American's Dream RP\gamemodes\ADRP.pwn(86308) : error 017: undefined symbol "VPos"
C:\Documents and Settings\Abdo\Bureau\American's Dream RP\gamemodes\ADRP.pwn(86308) : warning 215: expression has no effect
C:\Documents and Settings\Abdo\Bureau\American's Dream RP\gamemodes\ADRP.pwn(86308) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\Abdo\Bureau\American's Dream RP\gamemodes\ADRP.pwn(86308) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Abdo\Bureau\American's Dream RP\gamemodes\ADRP.pwn(86308) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


10 Errors.