small problems with a custom stock...
#1

hello I made a custom stock to easly compac teleport lines...
however I got a little problem with it...
here's the stock:
pawn Код:
stock AddPlayerTeleport(playerid, teleportname[], Float:x, Float:y, Float:z, TimeH, TimeM, bool:vehicleremove, Weapon, Ammo)
{
    new
        string[128],
        cartype = GetPlayerVehicleID(playerid);
    format(string, sizeof(string), "Teleported to %s", teleportname);
    SendClientMessage(playerid, COLOR_SEXYGREEN, string);
    ResetPlayerWeapons(playerid);
    SetPlayerTime(playerid, TimeH ,TimeM);
    SetTimer("LoadObjects", 1000, false);
    TogglePlayerControllable(playerid, false);
    GameTextForPlayer(playerid, "~r~Loading Objects...", 1000, 4);
    if(Weapon != -1)
        GivePlayerWeapon(playerid, Weapon, Ammo);
    if(vehicleremove == true){
        if(IsPlayerInAnyVehicle(playerid)){
            DestroyVehicle(cartype);
            }
        }

    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
        return SetPlayerPos(playerid,x ,y ,z);
    else if(IsPlayerInVehicle(playerid, cartype) == 1)
        return SetVehiclePos(cartype,x, y, z);

    return 1;
}
here some usages:

pawn Код:
if(!strcmp(cmdtext, "/island", true))
        return AddPlayerTeleport(playerid, "Chill-Island", 261.1905,-3271.4392,5.7316, 21, 0, true, -1, -1);
    if(!strcmp(cmdtext, "/chilliad", true))
        return AddPlayerTeleport(playerid, "MT Chilliad", -2344.8931,-1603.9287,489.2245, 12, 0, false, 46, 1);
    if(!strcmp(cmdtext, "/hh", true))
        return AddPlayerTeleport(playerid, "Huge Halfpipe", -1252.8372802734,-3572.2570800781,19.23807144165, 12, 0, false, -1, -1);
but I have got a little problem...
well
when I am in a vehicle and I teleport to something that should keep my vehicle, everything works...
when I am on foot and I teleport to something everything works

but when I am in a vehicle and I teleport to something that should destroy my vehicle and then teleport me there (because bool Vehicle remove was true) it gives me the message, the time and the weapons, but then it says unknown command and I don't get teleported...
rep for helper
Thanks in advance!
Reply
#2

PHP код:
stock AddPlayerTeleport(playeridteleportname[], Float:xFloat:yFloat:zTimeHTimeMbool:vehicleremoveWeaponAmmo)
{
    new
        
string[128],
        
cartype GetPlayerVehicleID(playerid);
    
format(stringsizeof(string), "Teleported to %s"teleportname);
    
SendClientMessage(playeridCOLOR_SEXYGREENstring);
    
ResetPlayerWeapons(playerid);
    
SetPlayerTime(playeridTimeH ,TimeM);
    
SetTimer("LoadObjects"1000false);
    
TogglePlayerControllable(playeridfalse);
    
GameTextForPlayer(playerid"~r~Loading Objects..."10004);
    if(
Weapon != -1GivePlayerWeapon(playeridWeaponAmmo);
    if(
vehicleremove == true) return SetPlayerPos(playerid,x,y,z);
    if(!
IsPlayerInAnyVehicle(playerid)) return SetPlayerPos(playerid,x,y,z);
    
seat GetPlayerVehicleSeat(playerid);
    
SetVehiclePos(cartype,x,y,z);
    
PutPlayerInVehicle(playerid,cartype,seat);
    return 
1;

Have fun.
Reply
#3

Thanks it works, but now when a player is in the passenger seat the entire vehicle will be teleported, so how do I prevent this and set that when the player is not the driver he will be removed out of the vehicle?
Reply
#4

PHP код:
stock AddPlayerTeleport(playeridteleportname[], Float:xFloat:yFloat:zTimeHTimeMbool:vehicleremoveWeaponAmmo)
{
    new
        
string[128],
        
cartype GetPlayerVehicleID(playerid);
    
format(stringsizeof(string), "Teleported to %s"teleportname);
    
SendClientMessage(playeridCOLOR_SEXYGREENstring);
    
ResetPlayerWeapons(playerid);
    
SetPlayerTime(playeridTimeH ,TimeM);
    
SetTimer("LoadObjects"1000false);
    
TogglePlayerControllable(playeridfalse);
    
GameTextForPlayer(playerid"~r~Loading Objects..."10004);
    if(
Weapon != -1GivePlayerWeapon(playeridWeaponAmmo);
    if(
vehicleremove == true) return SetPlayerPos(playerid,x,y,z);
    if(!
IsPlayerInAnyVehicle(playerid)) return SetPlayerPos(playerid,x,y,z);
    if(
GetPlayerVehicleSeat(playerid) !=0) return SetPlayerPos(playerid,x,y,z);
    
SetVehiclePos(cartype,x,y,z);
    
PutPlayerInVehicle(playerid,cartype,0);
    return 
1;

Reply
#5

thank you rep added!
Reply
#6

No problem
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)