SA-MP Forums Archive
small problems with a custom stock... - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: small problems with a custom stock... (/showthread.php?tid=294903)



small problems with a custom stock... - knackworst - 03.11.2011

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!


Re: small problems with a custom stock... - [MG]Dimi - 03.11.2011

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.


Re: small problems with a custom stock... - knackworst - 03.11.2011

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?


Re: small problems with a custom stock... - [MG]Dimi - 03.11.2011

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;




Re: small problems with a custom stock... - knackworst - 03.11.2011

thank you rep added!


Re: small problems with a custom stock... - [MG]Dimi - 03.11.2011

No problem