Destroy old jetpack when player spawns a new one? -
XpanD - 13.09.2010
Hi all,
I have recently made an admin-only command, /jetpack, available to all players on my server, meaning anybody can get a jetpack at any time. This all works fine, but there's one bug that's bound to be found and exploited eventually - if you get out of your jetpack and spawn another one, it does not delete the first one.
Using this trick you can make as many jetpacks as you want, which I assume could crash the server or cause other problems if one was dedicated enough to abuse it like that.
Here's my script, or at least the relevant part of it (boundary stuff excluded):
pawn Code:
if(AccountInfo[playerid][AdminLevel] <= 2 || !strlen(params) && AccountInfo[playerid][AdminLevel] >= 3)
{
SendClientMessage(playerid,COLOR_GREEN,"Enjoy your jetpack!");
ResetPlayerWeapons(playerid);
SetPlayerSpecialAction(playerid, 2);
}
else
{
new player1, string[128];
player1 = strval(params);
if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID)
{
SetPlayerSpecialAction(player1, 2);
format(string,sizeof(string),"Administrator \"%s\" has given you a free jetpack!", PlayerName2(playerid));
SendClientMessage(player1,COLOR_BLUE,string);
format(string,sizeof(string),"You have given \"%s\" a jetpack.", PlayerName2(player1));
SendClientMessage(playerid,COLOR_GREEN,string);
}
else SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected!");
}
I realize I could make a player-dependent variable, meaning that any player may only have one jetpack spawned at any time, but... If the player teleports away or dies, he will have to reconnect in order to be able to spawn another jetpack. That's not what I want - what I want is for any old jetpacks for one player to be deleted whenever he spawns a new one.
How would I go about doing this? Thanks in advance!
Re: Destroy old jetpack when player spawns a new one? -
mick88 - 13.09.2010
If player takes the jetpack off, he is the only one seeing the jetpack pickup, so other players can't have it. I don't know exactly what your problem is, maybe yoyu don't want player to get the jetpack back once they lose it? Then I'm afraid it's impossible...
Re: Destroy old jetpack when player spawns a new one? -
XpanD - 13.09.2010
Quote:
Originally Posted by mick88
If player takes the jetpack off, he is the only one seeing the jetpack pickup, so other players can't have it. I don't know exactly what your problem is, maybe yoyu don't want player to get the jetpack back once they lose it? Then I'm afraid it's impossible...
|
It doesn't show for other players? If so then that's perfect as is, but I didn't know stuff worked that way... :P
Re: Destroy old jetpack when player spawns a new one? -
Babul - 13.09.2010
dropped jetpacks seems to disappear after some time anyways. drop 1 or 2, teleport to some far position, and tele back. if they are still there, wait for them disappearing. maybe its 30 secs, maybe 1 minute...
Re: Destroy old jetpack when player spawns a new one? -
XpanD - 14.09.2010
Well, I just tested this with another player on a testing server, and we could both see the jetpacks I spawned. If somebody can confirm they disappear after a while that would be great. I'll probably test it myself later too.
Re: Destroy old jetpack when player spawns a new one? -
FireCat - 15.09.2010
well try
this
or
this
this isnt a script request xD i mean XpanD
Re: Destroy old jetpack when player spawns a new one? -
XpanD - 15.09.2010
Quote:
Originally Posted by FireCat
well try this
or this
this isnt a script request xD i mean XpanD
|
And when did you get unbanned...?
I have a piece of script logic I can't figure out so I post it here, asking for opinions. I already checked the wiki and forums but I could not find anything that helped me out in my specific situation.
Re: Destroy old jetpack when player spawns a new one? -
FireCat - 15.09.2010
lol well try getting some piece of s... i mean piece of code from your /nrg command and who sayed i was in your server
Re: Destroy old jetpack when player spawns a new one? -
willsuckformoney - 15.09.2010
maybe OnPlayerKeyStateChange, if they have a jetpack on then when they press waddder button is destroys the jetpack
Re: Destroy old jetpack when player spawns a new one? -
BP13 - 15.09.2010
If the player takes off the jetpack no one else can see it. There is also no limit for this. Your good to go.