27.08.2015, 22:38
i'm trying to make that if the player is already in a vehicle , it sends him the msg (You are already in a vehicle) , and when he spawns a vehicle the old vehicle he spawned should be destroyed , however , neither of the 2 conditions happen. In fact it sends the msg (You are already in a vehicle) if im NOT in a vehicle and vice versa
tell me if u want any other codes , Thanks
Код:
CMD:car(playerid,params[]) { if(IsPlayerInAnyVehicle(playerid)) { SendClientMessage(playerid,-1,"You are already in a vehicle!"); } else { new vehspawned; vehspawned = 0; new vehicleid; vehicleid = GetPlayerVehicleID(playerid); if(vehspawned == 1) { DestroyVehicle(vehicleid); vehspawned = 0; } new tmp[128], tmp2[128], tmp3[128], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index); tmp3 = strtok(params,Index); if(isnull(tmp)) return SendClientMessage(playerid, -1, "USAGE: /car [Modelid/Name] [colour1] [colour2]"); new car, colour1, colour2, string[128]; if(!IsNumeric(tmp)) car = GetVehicleModelIDFromName(tmp); else car = strval(tmp); if(car < 400 || car > 611) return SendClientMessage(playerid, -1, "ERROR: Invalid Vehicle Model"); if(isnull(tmp2)) colour1 = random(126); else colour1 = strval(tmp2); if(isnull(tmp3)) colour2 = random(126); else colour2 = strval(tmp3); new LVehicleID,Float:X,Float:Y,Float:Z, Float:Angle,int1; GetPlayerPos(playerid, X,Y,Z); GetPlayerFacingAngle(playerid,Angle); int1 = GetPlayerInterior(playerid); LVehicleID = CreateVehicle(car, X,Y,Z, Angle, colour1, colour2, -1); LinkVehicleToInterior(LVehicleID,int1); format(string, sizeof(string), "You have spawned a \"%s\" (Model:%d) colour (%d, %d)", VehicleName[car-400], car, colour1, colour2); PutPlayerInVehicle(playerid, LVehicleID, 0); VehicleInfo[LVehicleID][Temp] = 1; vehspawned = 1; return SendClientMessage(playerid,-1, string); } return 1; }