Destroy old jetpack when player spawns a new one?
#1

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!
Reply
#2

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...
Reply
#3

Quote:
Originally Posted by mick88
View Post
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
Reply
#4

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...
Reply
#5

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.
Reply
#6

well try this
or this
this isnt a script request xD i mean XpanD
Reply
#7

Quote:
Originally Posted by FireCat
View Post
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.
Reply
#8

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
Reply
#9

maybe OnPlayerKeyStateChange, if they have a jetpack on then when they press waddder button is destroys the jetpack
Reply
#10

If the player takes off the jetpack no one else can see it. There is also no limit for this. Your good to go.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)