I need help - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: I need help (
/showthread.php?tid=272600)
I need help -
Aleks1337 - 29.07.2011
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;
}
Re: I need help -
Horrible - 29.07.2011
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)
Re: I need help -
Aleks1337 - 29.07.2011
Thanks it worked now i just need it to give your weapons back too
Re: I need help -
Snipa - 29.07.2011
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.
Re: I need help -
Aleks1337 - 29.07.2011
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?
Re: I need help -
Aleks1337 - 29.07.2011
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
Re: I need help -
eDz0r - 29.07.2011
because the variable is global... not for player.....
Re: I need help -
Aleks1337 - 29.07.2011
how do i make it for just the player?
Re: I need help -
MadeMan - 29.07.2011
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]);
}
Re: I need help -
Aleks1337 - 29.07.2011
Thanks it worked