Spawning a trailer and then connecting it via dialog
#1

Im trying to create a fs where you can create a trailer and get it attached to your truck etc but im having some trouble spawning the actual trailers.

This is what i have

On top of FS
Quote:

new artic;
new artic2;
new artic3;
new petroltrailer;
new baggageA;
new baggageB;
new FarmTrailer;
new stairs;
new utility;

new plvehid = GetVehicleModel(GetPlayerVehicleID(playerid));

In Onplayercommandtext

Quote:

if (strcmp("/trailers", cmdtext, true, 10) == 0)
{
ShowPlayerDialog(playerid, 567, DIALOG_STYLE_LIST, "Trailer List", "Article Trailer\nArticle Trailer 2\nArticle Trailer 3\nPetrol Trailer\nBaggage Trailer A\nBaggage Trailer B\nFarm Trailer\nStairs Trailer\nUtility Trailer", "Select", "Cancel");
return 1;
}

Quote:

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if (dialogid == 567)
{
if (response == 1) // pistols
{
switch(listitem)
{
case 0:
{
new plvehid = GetVehicleModel(GetPlayerVehicleID(playerid));
if(plvehid == 403)
{
new Float:X, Float:Y, Float:Z;
new Float:Ang;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Ang);
artic = CreateVehicle(435,X+5,Y+5,Z,Ang,0,0,0);
AttachTrailerToVehicle(artic,plvehid);
}
else return SendClientMessage(playerid, COLOR_LIME, "Wrong Vehicle for this trailer.");

if(plvehid == 514)
{
new Float:X, Float:Y, Float:Z;
new Float:Ang;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Ang);
artic = CreateVehicle(435,X+5,Y+5,Z,Ang,0,0,0);
AttachTrailerToVehicle(artic,plvehid);
}
else return SendClientMessage(playerid, COLOR_LIME, "Wrong Vehicle for this trailer.");

if(plvehid == 515)
{
new Float:X, Float:Y, Float:Z;
new Float:Ang;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Ang);
artic = CreateVehicle(435,X+5,Y+5,Z,Ang,0,0,0);
AttachTrailerToVehicle(artic,plvehid);
}
else return SendClientMessage(playerid, COLOR_LIME, "Wrong Vehicle for this trailer.");

}
case 1:
{
new plvehid = GetVehicleModel(GetPlayerVehicleID(playerid));
if(plvehid == 403)
{
new Float:X, Float:Y, Float:Z;
new Float:Ang;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Ang);
artic2 = CreateVehicle(450,X+5,Y+5,Z,Ang,0,0,0);
AttachTrailerToVehicle(artic2,plvehid);
}
else return SendClientMessage(playerid, COLOR_LIME, "Wrong Vehicle for this trailer.");

if(plvehid == 514)
{
new Float:X, Float:Y, Float:Z;
new Float:Ang;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Ang);
artic2 = CreateVehicle(450,X+5,Y+5,Z,Ang,0,0,0);
AttachTrailerToVehicle(artic2,plvehid);
}
else return SendClientMessage(playerid, COLOR_LIME, "Wrong Vehicle for this trailer.");

if(plvehid == 515)
{
new Float:X, Float:Y, Float:Z;
new Float:Ang;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Ang);
artic2 = CreateVehicle(450,X+5,Y+5,Z,Ang,0,0,0);
AttachTrailerToVehicle(artic2,plvehid);
}
else return SendClientMessage(playerid, COLOR_LIME, "Wrong Vehicle for this trailer.");


}
case 2:
{
new plvehid = GetVehicleModel(GetPlayerVehicleID(playerid));
if(plvehid == 403)
{
new Float:X, Float:Y, Float:Z;
new Float:Ang;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Ang);
artic3 = CreateVehicle(491,X+5,Y+5,Z,Ang,0,0,0);
AttachTrailerToVehicle(artic3,plvehid);
}
else return SendClientMessage(playerid, COLOR_LIME, "Wrong Vehicle for this trailer.");

if(plvehid == 514)
{
new Float:X, Float:Y, Float:Z;
new Float:Ang;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Ang);
artic3 = CreateVehicle(491,X+5,Y+5,Z,Ang,0,0,0);
AttachTrailerToVehicle(artic3,plvehid);
}
else return SendClientMessage(playerid, COLOR_LIME, "Wrong Vehicle for this trailer.");

if(plvehid == 515)
{
new Float:X, Float:Y, Float:Z;
new Float:Ang;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Ang);
artic3 = CreateVehicle(491,X+5,Y+5,Z,Ang,0,0,0);
AttachTrailerToVehicle(artic3,plvehid);
}
else return SendClientMessage(playerid, COLOR_LIME, "Wrong Vehicle for this trailer.");

}
case 3:
{
new plvehid = GetVehicleModel(GetPlayerVehicleID(playerid));
if(plvehid == 403)
{
new Float:X, Float:Y, Float:Z;
new Float:Ang;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Ang);
petroltrailer = CreateVehicle(514,X+5,Y+5,Z,Ang,0,0,0);
AttachTrailerToVehicle(petroltrailer,plvehid);
}
else return SendClientMessage(playerid, COLOR_LIME, "Wrong Vehicle for this trailer.");

if(plvehid == 514)
{
new Float:X, Float:Y, Float:Z;
new Float:Ang;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Ang);
petroltrailer = CreateVehicle(514,X+5,Y+5,Z,Ang,0,0,0);
AttachTrailerToVehicle(petroltrailer,plvehid);
}
else return SendClientMessage(playerid, COLOR_LIME, "Wrong Vehicle for this trailer.");

if(plvehid == 515)
{
new Float:X, Float:Y, Float:Z;
new Float:Ang;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Ang);
petroltrailer = CreateVehicle(514,X+5,Y+5,Z,Ang,0,0,0);
AttachTrailerToVehicle(petroltrailer,plvehid);
}
else return SendClientMessage(playerid, COLOR_LIME, "Wrong Vehicle for this trailer.");

}
case 4:
{
new plvehid = GetVehicleModel(GetPlayerVehicleID(playerid));
if(plvehid == 485)
{
new Float:X, Float:Y, Float:Z;
new Float:Ang;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Ang);
baggageA = CreateVehicle(606,X+5,Y+5,Z,Ang,0,0,0);
AttachTrailerToVehicle(baggageA,plvehid);
}
else return SendClientMessage(playerid, COLOR_LIME, "Wrong Vehicle for this trailer.");

if(plvehid == 583)
{
new Float:X, Float:Y, Float:Z;
new Float:Ang;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Ang);
baggageA = CreateVehicle(606,X+5,Y+5,Z,Ang,0,0,0);
AttachTrailerToVehicle(baggageA,plvehid);
}
else return SendClientMessage(playerid, COLOR_LIME, "Wrong Vehicle for this trailer.");

}
case 5:
{
new plvehid = GetVehicleModel(GetPlayerVehicleID(playerid));
if(plvehid == 485)
{
new Float:X, Float:Y, Float:Z;
new Float:Ang;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Ang);
baggageB = CreateVehicle(607,X+5,Y+5,Z,Ang,0,0,0);
AttachTrailerToVehicle(baggageB,plvehid);
}
else return SendClientMessage(playerid, COLOR_LIME, "Wrong Vehicle for this trailer.");

if(plvehid == 583)
{
new Float:X, Float:Y, Float:Z;
new Float:Ang;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Ang);
baggageB = CreateVehicle(607,X+5,Y+5,Z,Ang,0,0,0);
AttachTrailerToVehicle(baggageB,plvehid);
}
else return SendClientMessage(playerid, COLOR_LIME, "Wrong Vehicle for this trailer.");

}
case 6:
{
new plvehid = GetVehicleModel(GetPlayerVehicleID(playerid));
if(plvehid == 531)
{
new Float:X, Float:Y, Float:Z;
new Float:Ang;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Ang);
FarmTrailer = CreateVehicle(610,X+5,Y+5,Z,Ang,0,0,0);
AttachTrailerToVehicle(FarmTrailer,plvehid);
}
else return SendClientMessage(playerid, COLOR_LIME, "Wrong Vehicle for this trailer.");

}
case 7:
{
new plvehid = GetVehicleModel(GetPlayerVehicleID(playerid));
if(plvehid == 485)
{
new Float:X, Float:Y, Float:Z;
new Float:Ang;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Ang);
stairs = CreateVehicle(608,X+5,Y+5,Z,Ang,0,0,0);
AttachTrailerToVehicle(stairs,plvehid);
}
else return SendClientMessage(playerid, COLOR_LIME, "Wrong Vehicle for this trailer.");

if(plvehid == 583)
{
new Float:X, Float:Y, Float:Z;
new Float:Ang;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Ang);
stairs = CreateVehicle(608,X+5,Y+5,Z,Ang,0,0,0);
AttachTrailerToVehicle(stairs,plvehid);
}
else return SendClientMessage(playerid, COLOR_LIME, "Wrong Vehicle for this trailer.");
}
case 8:
{
new plvehid = GetVehicleModel(GetPlayerVehicleID(playerid));
if(plvehid == 485)
{
new Float:X, Float:Y, Float:Z;
new Float:Ang;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Ang);
utility = CreateVehicle(611,X+5,Y+5,Z,Ang,0,0,0);
AttachTrailerToVehicle(utility,plvehid);
}
else return SendClientMessage(playerid, COLOR_LIME, "Wrong Vehicle for this trailer.");

if(plvehid == 583)
{
new Float:X, Float:Y, Float:Z;
new Float:Ang;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Ang);
utility = CreateVehicle(611,X+5,Y+5,Z,Ang,0,0,0);
AttachTrailerToVehicle(utility,plvehid);
}
else return SendClientMessage(playerid, COLOR_LIME, "Wrong Vehicle for this trailer.");
}
}
}
}
return 1;
}

Now for some reason the trailers don't spawn. Can someone please look over my FS and see whats causing it them not to spawn?
Reply
#2

GetPlayerVehicleID(playrid) not get model model is the shape of the car
Reply
#3

Ye, change plvehid to GetPlayerVehicleID
Reply
#4

Give this a whirl. Should be a much better version. Btw, this will run standalone.

http://pastebin.com/cs2bE3N3
Reply
#5

yeah nice code banana, except the commands dont work.
Reply
#6

What commands?
Reply
#7

this bit..
Quote:

public OnPlayerCommandText(playerid,cmdtext[])
{
if(!strcmp("/trailers",cmdtext,true))
{
ShowPlayerDialog(playerid, 567, DIALOG_STYLE_LIST, "Trailer List", "Article Trailer\nArticle Trailer 2\nArticle Trailer 3\nPetrol Trailer\nBaggage Trailer A\nBaggage Trailer B\nFarm Trailer\nStairs Trailer\nUtility Trailer", "Select", "Cancel");
return 1;
}
return 0;
}

not sure why, but it doesnt work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)