/park for private vehicles! -
NitoPSG - 19.04.2011
i have created private cars using this code
http://forum.sa-mp.com/showthread.ph...e+car+parkable , so i want to make a /park command to park the private cars and respawn them in the place i parked last time, how to do this
Re: /park for private vehicles! -
austin070 - 19.04.2011
You need to use a file writing system such as dini or Y_ini. Here is an example of a park command with ZCMD.
pawn Код:
CMD:park(playerid, params[])
{
new Float:X, Float:Y, Float:Z, Float:A, file[128];
format(file, sizeof(file), VEH_FILE, GetPlayerVehicleID(playerid));
GetVehiclePos(GetPlayerVehicleID(playerid), X, Y, Z);
GetVehicleZAngle(GetPlayerVehicleID(playerid), A);
dini_FloatSet(file, "XPos", X);
dini_FloatSet(file, "YPos", Y);
dini_FloatSet(file, "ZPos", Z);
dini_FloatSet(file, "Rot", A);
SendClientMessage(playerid, COLOR, "Your vehicle's position has been saved.");
return 1;
}
public OnVehicleSpawn(..)
{
new file[128];
format(file, sizeof(file), VEH_FILE, GetPlayerVehicleID(playerid));
if(fexists(file))
{
SetVehiclePos(vehicleid, dini_Float(file, "XPos"),dini_Float(file, "YPos"),dini_Float(file, "ZPos"));
SetVehicleZAngle(vehicleid, dini_Float(file, "Rot");
}
return 1;
}
Make sure you change "COLOR" to one of your defined colors. You also need to define a vehicle directory file such as:
pawn Код:
#define VEH_FILE "Vehicles\\%i.ini"
This would be in your scriptfiles folder. You can change VEH_FILE to anything as long as the one in the script corresponds with the defined one. You need to make a folder in your scriptfiles called "Vehicles" if you use this define.
Re: /park for private vehicles! -
NitoPSG - 19.04.2011
Quote:
Originally Posted by austin070
You need to use a file writing system such as dini or Y_ini. Here is an example of a park command with ZCMD.
pawn Код:
CMD:park(playerid, params[]) { new Float:X, Float:Y, Float:Z, Float:A, file[128]; format(file, sizeof(file), VEH_FILE, GetPlayerVehicleID(playerid)); GetVehiclePos(GetPlayerVehicleID(playerid), X, Y, Z); GetVehicleZAngle(GetPlayerVehicleID(playerid), A); dini_FloatSet(file, "XPos", X); dini_FloatSet(file, "YPos", Y); dini_FloatSet(file, "ZPos", Z); dini_FloatSet(file, "Rot", A); SendClientMessage(playerid, COLOR, "Your vehicle's position has been saved."); return 1; } public OnVehicleSpawn(..) { new file[128]; format(file, sizeof(file), VEH_FILE, GetPlayerVehicleID(playerid)); if(fexists(file)) { SetVehiclePos(vehicleid, dini_Float(file, "XPos"),dini_Float(file, "YPos"),dini_Float(file, "ZPos")); SetVehicleZAngle(vehicleid, dini_Float(file, "Rot"); } return 1; }
Make sure you change "COLOR" to one of your defined colors. You also need to define a vehicle directory file such as:
pawn Код:
#define VEH_FILE "Vehicles\\%i.ini"
This would be in your scriptfiles folder. You can change VEH_FILE to anything as long as the one in the script corresponds with the defined one. You need to make a folder in your scriptfiles called "Vehicles" if you use this define.
|
C:\Documents and Settings\User\Desktop\park.pwn(93) : error 017: undefined symbol "park"
C:\Documents and Settings\User\Desktop\park.pwn(94) : warning 217: loose indentation
C:\Documents and Settings\User\Desktop\park.pwn(96) : error 017: undefined symbol "Vehicle"
C:\Documents and Settings\User\Desktop\park.pwn(99) : error 017: undefined symbol "dini_FloatSet"
C:\Documents and Settings\User\Desktop\park.pwn(100) : error 017: undefined symbol "dini_FloatSet"
C:\Documents and Settings\User\Desktop\park.pwn(101) : error 017: undefined symbol "dini_FloatSet"
C:\Documents and Settings\User\Desktop\park.pwn(102) : error 017: undefined symbol "dini_FloatSet"
C:\Documents and Settings\User\Desktop\park.pwn(106) : warning 225: unreachable code
C:\Documents and Settings\User\Desktop\park.pwn(106) : error 029: invalid expression, assumed zero
C:\Documents and Settings\User\Desktop\park.pwn(106) : error 029: invalid expression, assumed zero
C:\Documents and Settings\User\Desktop\park.pwn(109) : error 017: undefined symbol "Vehicle"
C:\Documents and Settings\User\Desktop\park.pwn(110) : error 017: undefined symbol "fexists"
C:\Documents and Settings\User\Desktop\park.pwn(112) : error 017: undefined symbol "vehicleid"
C:\Documents and Settings\User\Desktop\park.pwn(113) : error 017: undefined symbol "vehicleid"
C:\Documents and Settings\User\Desktop\park.pwn(113) : error 001: expected token: ",", but found ";"
C:\Documents and Settings\User\Desktop\park.pwn(117) : warning 225: unreachable code
C:\Documents and Settings\User\Desktop\park.pwn(117) : warning 217: loose indentation
C:\Documents and Settings\User\Desktop\park.pwn(93) : warning 203: symbol is never used: "CMD"
i got this errors my brother :/
Can you please help me?? i really need this, Where is the problem?
Re: /park for private vehicles! -
NitoPSG - 19.04.2011
Anyone can help me? :/
Re: /park for private vehicles! -
NitoPSG - 20.04.2011
?
Re: /park for private vehicles! -
SomebodyAndMe - 20.04.2011
Try to add at the top of your script:
https://sampforum.blast.hk/showthread.php?tid=91354 THis is the ZCMD Include <<<<<<