Trucking script Help -
Zigonja - 31.05.2013
This is the code im using for command /unloadlogs, it's same for /loadlogs witch doesn't work either.
However, after testing the script for some time, I can't get it why spawning truckID 422, at the right location still gives me "You are not in a truck, that can deliver logs!"
pawn Код:
if (strcmp("/unloadlogs", cmdtext, true, 10) == 0)
{
if(GetPlayerScore(playerid) >= -500)
{
if(IsPlayerInRangeOfPoint(playerid, 7.0, 2334.8611, -2081.3384, 13.5469))
{
if(GetPlayerVehicleID(422))
{
if(CarInfo[GetPlayerVehicleID(422)] [logs] == 1)
{
CarInfo[GetPlayerVehicleID(422)][logs] = 0;
new cash = random(30000);
GivePlayerMoney(playerid, cash);
new string[128];
format(string,sizeof(string),"You earned %d$ from the delivery",cash);
SendClientMessage(playerid,COLOR_GREEN,string);
}
else
{
SendClientMessage(playerid, COLOR_RED, "Your truck is empety!");
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "You are not in a truck, that can deliver logs!");
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "You cannot unload your truck here!");
}
}
Thanks for help in advance!
Re: Trucking script Help -
mahdi499 - 31.05.2013
As i know the function
pawn Код:
GetPlayerVehicleID(playerid);
You get his vehicle id,and it can't be changed to a car id. so i beleive it's like
pawn Код:
if (strcmp("/unloadlogs", cmdtext, true, 10) == 0)
{
if(GetPlayerScore(playerid) >= -500)
{
if(IsPlayerInRangeOfPoint(playerid, 7.0, 2334.8611, -2081.3384, 13.5469))
{
new Vehid = GetPlayerVehicleID(playerid);
if(Vehdid == 422)
{
if(CarInfo[Vehid] [logs] == 1)
{
CarInfo[Vehid][logs] = 0;
new cash = random(30000);
GivePlayerMoney(playerid, cash);
new string[128];
format(string,sizeof(string),"You earned %d$ from the delivery",cash);
SendClientMessage(playerid,COLOR_GREEN,string);
}
else
{
SendClientMessage(playerid, COLOR_RED, "Your truck is empety!");
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "You are not in a truck, that can deliver logs!");
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "You cannot unload your truck here!");
}
}
Re: Trucking script Help -
Zigonja - 31.05.2013
It gives out an error now
Код:
C:\Users\Ziga\Desktop\RP Skripta\Raven's Roleplay 0.3x\filterscripts\woodtrucking.pwn(101) : error 017: undefined symbol "Vehdid"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Error.
Re: Trucking script Help -
mahdi499 - 31.05.2013
yeah in the Vehdid == 422 fix it to Vehid == 422
Re: Trucking script Help -
Pottus - 31.05.2013
Trying to determine something like this if(Vehdid == 422) is completely ass backwards if you delete or create a vehicle anywhere before this it will mess up all your code completely. Whoever thought that would be a good idea needs some lessons in dynamic design.
Re: Trucking script Help -
Zigonja - 31.05.2013
Yeah srry, im blind xD
But it still gives out "You are not in a truck, that can deliver logs!"
Re: Trucking script Help -
Pottus - 31.05.2013
Read what I said, you probably deleted or created a vehicle before this one it's a terrible design and this is why you create proper dynamic systems relying on specific vehicle id's and expecting them not to change during development is a terrible assumption. Fortunately this is a very easy problem I'll give you an example however it will require updating all of your code.
pawn Код:
#define CAR_TYPE_COPCAR 0
new gCarData[MAX_VEHICLES] = { INVALID_VEHICLE_ID, ... };
public OnGameModeInit()
{
AddDynamicCar(596,1595.3313,-1709.8433,5.6725,180.4009,16,1, 3600, CAR_TYPE_COPCAR);
}
stock AddDynamicCar(model, Float:cx, Float:cy: Float:cz, Float:cfa, color1, color2, respawndelay, cartype)
{
new vindex = CreateVehicle(modelid, cx, cy, cz, cfa, color1, color2, respawndelay);
if(vindex != INVALID_VEHICLE_ID)
{
gCarData[vindex] = cartype;
return vindex;
}
return INVALID_VEHICLE_ID;
}
stock IsACopCar(carid)
{
if(gCarData[carid] == CAR_TYPE_COPCAR) return 1;
return 0;
}
You can add any number of vehicle types to that for instance for your logging truck you would need to add..
pawn Код:
#define CAR_TYPE_LOGGING 1
The number doesn't really matter it is a reference, when creating
AddDynamicCar(596,1595.3313,-1709.8433,5.6725,180.4009,16,1, 3600, CAR_TYPE_LOGGING );
Checking
stock IsALogging(carid)
{
if(gCarData[carid] == CAR_TYPE_LOGGING) return 1;
return 0;
}
How this relates to your code
if(Vehdid == 422)
becomes
if(IsALogging(GetPlayerVehicleID(playerid))
No fuss no bullshit no problems no matter what order your vehicles are created in.
Re: Trucking script Help -
Zigonja - 31.05.2013
I am begginer in scripting and I don't really know how to script dinamcaly yet.. And vehicle was created after I imported the scipt
EDIT: But my gamemode is a RP one, and I want people to buy a truck, to actually be able to deliver. But as I guess Dynamic car system spawns in a car, that stay there isn't it so?
Re: Trucking script Help -
Zigonja - 31.05.2013
This is how my code looks now:
pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT
#include <a_samp>
#if defined FILTERSCRIPT
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define CAR_TYPE_LOGGING 422
new gCarData[MAX_VEHICLES] = { INVALID_VEHICLE_ID, ... };
public OnFilterScriptInit()
{
AddDynamicCar(422,1595.3313,-1709.8433,5.6725,180.4009,16,1, 3600, CAR_TYPE_LOGGING );
print("\n--------------------------------------");
print(" Blank Filterscript by your name here");
print("--------------------------------------\n");
return 1;
}
stock AddDynamicCar(modelid, Float:cx, Float:cy, Float:cz, Float:cfa, color1, color2, respawndelay, cartype)
{
new vindex = CreateVehicle(modelid, cx, cy, cz, cfa, color1, color2, respawndelay);
if(vindex != INVALID_VEHICLE_ID)
{
gCarData[vindex] = cartype;
return vindex;
}
return INVALID_VEHICLE_ID;
}
enum cInfo
{
logs
};
new CarInfo[1][cInfo];
public OnFilterScriptExit()
{
return 1;
}
#else
main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}
#endif
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}
stock IsALogging(carid)
{
if(gCarData[carid] == CAR_TYPE_LOGGING) return 1;
return 0;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/loadlogs", cmdtext, true, 10) == 0)
{
if(GetPlayerScore(playerid) >= -500)
{
if(IsPlayerInRangeOfPoint(playerid, 7.0, -1969.5801, -2431.8479, 30.6250))
{
new vehid = GetPlayerVehicleID(playerid);
if(IsALogging(vehid))
{
if(CarInfo[IsALogging(vehid)][logs] == 0)
{
CarInfo[IsALogging(vehid)][logs] = 1;
GivePlayerMoney(playerid, -3000);
SendClientMessage(playerid, COLOR_GREEN, "You loaded full truck of logs, and paid $3000 for it! Head to unload place!");
}
else
{
SendClientMessage(playerid, COLOR_RED, "Your truck is already loaded!");
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "You're not in truck, that can deliver logs!");
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "You cannot load your truck here!");
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "Your job isn't trucker!");
}
return 1;
}
if (strcmp("/unloadlogs", cmdtext, true, 10) == 0)
{
if(GetPlayerScore(playerid) >= -500)
{
if(IsPlayerInRangeOfPoint(playerid, 7.0, 2334.8611, -2081.3384, 13.5469))
{
new Vehid = GetPlayerVehicleID(playerid);
if(Vehid == 422)
{
if(CarInfo[Vehid] [logs] == 1)
{
CarInfo[Vehid][logs] = 0;
new cash = random(30000);
GivePlayerMoney(playerid, cash);
new string[128];
format(string,sizeof(string),"You earned %d$ from the delivery",cash);
SendClientMessage(playerid,COLOR_GREEN,string);
}
else
{
SendClientMessage(playerid, COLOR_RED, "Your truck is empety!");
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "You are not in a truck, that can deliver logs!");
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "You cannot unload your truck here!");
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "You are not a trucker!");
}
return 1;
}
if (strcmp("/frisktruck", cmdtext, true, 10) == 0)
{
if(GetPlayerScore(playerid) >= -500)
{
new vehicleid1 = GetPlayerVehicleID(playerid);
if(vehicleid1 == 422)
{
if(CarInfo[vehicleid1][logs] == 1)
{
if(CarInfo[vehicleid1][logs] == 0)
{
SendClientMessage(playerid, COLOR_GREEN, "Logs not loaded.");
}
else if(CarInfo[vehicleid1][logs] == 1)
{
SendClientMessage(playerid, COLOR_GREEN, "Logs loaded.");
}
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "This truck cannot deliver logs!");
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "You cannot use this command!");
}
}
return 0;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}
It doesn't give out any errors but it still says "You're not in truck, that can deliver logs!"
Also I know, I didn't apply anything for /frisktruck and /unloadlogs yet but I will if I get fix for /loadiron
Re: Trucking script Help -
Zigonja - 31.05.2013
Bump, I really need fix for this