13.09.2010, 11:51
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):
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!
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!");
}
How would I go about doing this? Thanks in advance!