something broke -
kylebrown - 09.12.2009
i have a FS i made but no matter witch command i type in it dose /hydra. i.e /GMX spawns you a hydra, its ment to restart the server!
code or
http://pastebin.com/f2100c1ef
EDIT:Just found out no matter what you put in it spawns a hydra!!!
Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#include <a_samp>
//-----------------------------------------------
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Commands by Kylebrown 2009");
print("--------------------------------------\n");
return 1;
}
//---------------------------------------------------
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256];
new string[256];
new giveplayerid;
// if (strcmp("/mycommand", cmdtext, true, 10) == 0)
// {
// // Do something here
// return 1;
// }
if(strcmp(cmd, "/Hydra", true) == 0)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
PutPlayerInVehicle(playerid,CreateVehicle(520, x, y, z, 82.2873, 0, 1, 0),0);
SendClientMessageToAll(COLOR_YELLOW, "One Hydra :) Happy Flying");
return 1;
}
if(strcmp(cmd, "/GMX", true) == 0)
{
if(IsPlayerAdmin(playerid))
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "!!!!!%s RESTARTED THE SERVER!!!!!!", name);
SendClientMessageToAll(COLOR_YELLOW, string);
SendRconCommand("gmx");
}
else {
format(string, sizeof(string), "Your NOT an ADMIN, YOU have NO rights!.", giveplayerid);
SendClientMessage(playerid, COLOR_YELLOW, string);
}
return 1;
}
return 0;
}
//---------------------------------------------------------------
public OnFilterScriptExit()
{
return 1;
}
Re: something broke -
Mikep. - 09.12.2009
There are so many things wrong with that code.
• The indentation is awful.
• You spelt 'You're' wrong.
• You format a message but don't need to
• You have unnecessary else's
• You have misplaced brackets and returns
• giveplayerid, cmd, and tmp are never used (cmd is empty, that's why it spawns a hydra.)
Also don't use the #define FILTERSCRIPT stuff, just remove it.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/hydra", true))
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
PutPlayerInVehicle(playerid,CreateVehicle(520, x, y, z, 82.2873, 0, 1, 0),0);
SendClientMessageToAll(COLOR_YELLOW, "One Hydra :) Happy Flying!");
return 1;
}
if(!strcmp(cmdtext, "/gmx", true))
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_YELLOW, "You're not an admin.");
new name[MAX_PLAYER_NAME],string[64];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "!!!!! %s RESTARTED THE SERVER !!!!!!", name);
SendClientMessageToAll(COLOR_YELLOW, string);
SendRconCommand("gmx");
return 1;
}
return 0;
}
Re: something broke -
kylebrown - 09.12.2009
thanks for your help, my indentation is fine in the editor but as soon as i copyed it it went all screwy
i'll post back if it works
EDIT: IT WORKS. thank you very much!!
Re: something broke -
Mikep. - 09.12.2009
No I mean, don't do stuff like:
It makes it very hard to read, and when you have a 20,000 line script and fuck something up, beleive me it will take you weeks to find the problem.
Re: something broke -
kylebrown - 10.12.2009
that was no me that did that bit of code that was from the fourms