Megítram neked (nem teszteltem)
#include <a_samp>
#include <zcmd>
new Float:pX, Float:pY, Float:pZ, Float:vX, Float:vY, Float:vZ, Found=0, vid=0;
public OnPlayerConnect(playerid) return SetPVarInt(playerid, \"vankötél\", 0);
CMD:vontat(playerid, params[])
{
#pragma unused params
if(GetPVarInt(playerid, \"vankötél\") == 1)
{
if(IsPlayerInAnyVehicle(playerid))
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
GetPlayerPos(playerid,pX,pY,pZ);
while((vid<MAX_VEHICLES) && (!Found))
{
vid++;
GetVehiclePos(vid,vX,vY,vZ);
if((floatabs(pX-vX)<7.0)&&(floatabs(pY-vY)<7.0)&&(floatabs(pZ-vZ)<7.0)&&(vid!=GetPlayerVehicleID(playerid)))
{
Found=1;
if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)))
{
DetachTrailerFromVehicle(GetPlayerVehicleID(playerid));
}
else
{
AttachTrailerToVehicle(vid,GetPlayerVehicleID(playerid));
}
}
}
if(!Found)
{
SendClientMessage(playerid,0x00FF00FF,\"Nincs jármû a közelbe.\");
}
}
else
{
SendClientMessage(playerid, 0x00FF00FF, \"Jármûben kell lenned!\");
return 1;
}
}
else
{
SendClientMessage(playerid,0x00FF00FF,\"Nincs vontató köteled!\");
return 1;
}
}
return 1;
}
CMD:buykotel(playerid, params[])
{
#pragma unused params
if(GetPlayerMoney(playerid) < 4999) return SendClientMessage(playerid, 0x00FF00FF, \"Nincs rá pénzed! 5000-be kerül\");
if(GetPVarInt(playerid, \"vankötél\") == 0)
{
SetPVarInt(playerid, \"vankötél\", 1);
SendClientMessage(playerid, 0x00FF00FF, \"Vettél egy vontatókötelet!\");
GivePlayerMoney(playerid, -5000);
}
else if(GetPVarInt(playerid, \"vankötél\") == 1)
{
SendClientMessage(playerid, 0x00FF00FF, \"Már van vontatóköteled!\");
}
return 1;
}
Elnéztem, bocs.
new Float:pX, Float:pY, Float:pZ, Float:vX, Float:vY, Float:vZ, Found=0, vid=0;
if(strcmp(cmdtext, \"/vontat\", true)==0)
{
if(IsPlayerInAnyVehicle(playerid))
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
GetPlayerPos(playerid,pX,pY,pZ);
while((vid<MAX_VEHICLES) && (!Found))
{
vid++;
GetVehiclePos(vid,vX,vY,vZ);
if((floatabs(pX-vX)<7.0)&&(floatabs(pY-vY)<7.0)&&(floatabs(pZ-vZ)<7.0)&&(vid!=GetPlayerVehicleID(playerid)))
{
Found=1;
if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)))
{
DetachTrailerFromVehicle(GetPlayerVehicleID(playerid));
} else {
AttachTrailerToVehicle(vid,GetPlayerVehicleID(playerid));
}
}
}
if(!Found)
{
SendClientMessage(playerid,0x00FF00FF,\"Nincs jármû a közelbe.\");
}
} else {
SendClientMessage(playerid, 0x00FF00FF, \"Jármûben kell lenned!\");
return 1;
}
}
return 1;
}