I need help
#1

i made a teleport called /chill and when u wanna leave you type /exitchill, now i wanna make it so when you type /exitchill it takes you back to the where you were before you typed /chill and it gives you back your weapons

Heres the code for /chill
pawn Код:
if (strcmp(cmdtext, "/chill", true) == 0)//code credits: Sideways
    {          
            if(InDm[playerid] == 1)
        {
        SendClientMessage(playerid, COLOR_RED,"Error: You cannot use this command in a DM! You must /leavedm first.");
        return 1;
        }
            SetPlayerInterior(playerid,5);
            SetPlayerPos(playerid,1270.38,-787.42,1084.01);
            ResetPlayerWeapons(playerid);//Takes weapons
            SetPlayerHealth(playerid, 100000);
            SendClientMessage(playerid, blue, "{FFFFFF}Welcome to the chill zone");
            SendClientMessage(playerid, blue, "{FFFFFF}We have taken your weapons away because there is{FF0000} NO KILLING{FFFFFF} in the chill zone");
            SendClientMessage(playerid, blue, "{FFFFFF}To exit the chill zone type{00FF00} /exitchill");
            InChill[playerid] = 1;
            return 1;
        }
And Heres the code for /exitchill
pawn Код:
if (strcmp(cmdtext, "/exitchill", true) == 0)            //code credits: Sideways
        {
            if(InChill[playerid] == 0)
        {
        SendClientMessage(playerid, COLOR_RED,"Error: You are not in Chill.");
        return 1;
        }
            SetPlayerInterior(playerid,0);
            SetPlayerPos(playerid,2153.87,935.24,10.82);
            GivePlayerWeapon(playerid, 22, 500);//gives the player a 9mm with 500 rounds of ammo
            SetPlayerHealth(playerid, 100);
            SendClientMessage(playerid, blue, "{FFFFFF}Welcome to the DM zone");
            SendClientMessage(playerid, blue, "{FF0000}Your weapons were not given back");
            InChill[playerid] = 0;
            return 1;
        }
Reply
#2

Quote:
Originally Posted by Aleks1337
Посмотреть сообщение
i made a teleport called /chill and when u wanna leave you type /exitchill, now i wanna make it so when you type /exitchill it takes you back to the where you were before you typed /chill and it gives you back your weapons

Heres the code for /chill
pawn Код:
if (strcmp(cmdtext, "/chill", true) == 0)//code credits: Sideways
    {          
            if(InDm[playerid] == 1)
        {
        SendClientMessage(playerid, COLOR_RED,"Error: You cannot use this command in a DM! You must /leavedm first.");
        return 1;
        }
            SetPlayerInterior(playerid,5);
            SetPlayerPos(playerid,1270.38,-787.42,1084.01);
            ResetPlayerWeapons(playerid);//Takes weapons
            SetPlayerHealth(playerid, 100000);
            SendClientMessage(playerid, blue, "{FFFFFF}Welcome to the chill zone");
            SendClientMessage(playerid, blue, "{FFFFFF}We have taken your weapons away because there is{FF0000} NO KILLING{FFFFFF} in the chill zone");
            SendClientMessage(playerid, blue, "{FFFFFF}To exit the chill zone type{00FF00} /exitchill");
            InChill[playerid] = 1;
            return 1;
        }
And Heres the code for /exitchill
pawn Код:
if (strcmp(cmdtext, "/exitchill", true) == 0)            //code credits: Sideways
        {
            if(InChill[playerid] == 0)
        {
        SendClientMessage(playerid, COLOR_RED,"Error: You are not in Chill.");
        return 1;
        }
            SetPlayerInterior(playerid,0);
            SetPlayerPos(playerid,2153.87,935.24,10.82);
            GivePlayerWeapon(playerid, 22, 500);//gives the player a 9mm with 500 rounds of ammo
            SetPlayerHealth(playerid, 100);
            SendClientMessage(playerid, blue, "{FFFFFF}Welcome to the DM zone");
            SendClientMessage(playerid, blue, "{FF0000}Your weapons were not given back");
            InChill[playerid] = 0;
            return 1;
        }
add this to your top of script
pawn Код:
new Float:x, Float:y, Float:z;
add this to your /chill
pawn Код:
GetPlayerPos(playerid, x, y, z)
and add this to /exitchill
pawn Код:
SetPlayerPos(playerid, x, y, z)
Reply
#3

Thanks it worked now i just need it to give your weapons back too
Reply
#4

Quote:
Originally Posted by Aleks1337
Посмотреть сообщение
Thanks it worked now i just need it to give your weapons back too
When they enter, store their weapons into variables via GetPlayerWeaponData, then when they exit, GivePlayerWeapon.
Reply
#5

Quote:
Originally Posted by Snipa
Посмотреть сообщение
When they enter, store their weapons into variables via GetPlayerWeaponData, then when they exit, GivePlayerWeapon.
i don't understand can u show me the code the way Horrible did?
Reply
#6

i just noticed a problem, when i type /chill i teleport there and my friend types /chill and he teleports there but when i type /exitchill i teleport to where my friend was before he typed /chill instead of teleporting to where i was before i typed /chill
Reply
#7

because the variable is global... not for player.....
Reply
#8

how do i make it for just the player?
Reply
#9

pawn Код:
new Float:LastPos[MAX_PLAYERS][3];
new LastWeapons[MAX_PLAYERS][14][2];
/chill
pawn Код:
GetPlayerPos(playerid, LastPos[playerid][0], LastPos[playerid][1], LastPos[playerid][2]);
for(new i=0; i < sizeof(LastWeapons[]); i++)
{
    GetPlayerWeaponData(playerid, i, LastWeapons[playerid][i][0], LastWeapons[playerid][i][1]);
}
/exitchill
pawn Код:
SetPlayerPos(playerid, LastPos[playerid][0], LastPos[playerid][1], LastPos[playerid][2]);
for(new i=0; i < sizeof(LastWeapons[]); i++)
{
    GivePlayerWeapon(playerid, LastWeapons[playerid][i][0], LastWeapons[playerid][i][1]);
}
Reply
#10

Thanks it worked
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)