24.06.2012, 22:19
one rule i never break, is:
mkay, with some exceptions, like code which will never be touched anymore - its easier to end with 1 line when collapsing callbacks/other nested lines
look at a simple toggle command, the 1st 3rd line got the { bracket at the end. bad practise, but you get the point, when you see the "fake" collapsed code (in fact: how it looks to me)...
the full thing:
collapsed the switch-line (imagine a + symbol indicating a collapsed line, so the [ only is ok here:
i promise, if you nest each single line, and indent your code, you will never fail at such shit again.
edit: oh, here's your code, i changed "nothing" except swapping 2 lines and copying 1 hehe
edit2:
may i ask what the ringtones are? numerical values or strings for streaming audio? or both? since the value is a single cell, its a good idea to change the sscanf specifier from "s" to "d" maybe? what if the player inputs a string? then the value is indeed a string:
.. and makes the specifier change obsolete.. argh
Код:
if (you write an "if" in your script) { fuckin' indent. your TAB key is not that [ ] fat to be ignored. }
look at a simple toggle command, the 1st 3rd line got the { bracket at the end. bad practise, but you get the point, when you see the "fake" collapsed code (in fact: how it looks to me)...
the full thing:
pawn Код:
CMD:insert(playerid,cmdtext[]){
InsertMode=1-InsertMode;
switch(InsertMode){
case 0:
{
SendClientMessage(playerid,MSGCMDS_COLOR,"Insertion Mode {ffaaaa}disabled");
}
case 1:
{
SendClientMessage(playerid,MSGCMDS_COLOR,"Insertion Mode {aaffaa}enabled");
}
}
return 1;
}
pawn Код:
CMD:insert(playerid,cmdtext[]){
InsertMode=1-InsertMode;
switch(InsertMode){ //nested, collapsed stuff inside
return 1;
}
edit: oh, here's your code, i changed "nothing" except swapping 2 lines and copying 1 hehe
pawn Код:
CMD:setringtone(playerid, params[])
{
new
value,
str[295],
string[295],
pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
if(PlayerInfo[playerid][pWrestler] >= 1)
{
if(sscanf(params, "s", value))
{
SendClientMessage(playerid, -1, "Syntax: /setringtone [url/ringotne]");
SendClientMessage(playerid, -1, "For Example: http://YOUR_URL_OF_THE_SONG");
PlayerInfo[playerid][pRingTone] = value; //<<< fixed
return true;//this line could be deleted for now, below is another one. but if theres some stuff you want to be done incase the wrestler- or value-check fails, that line should stay.
}
}
return true;
}
may i ask what the ringtones are? numerical values or strings for streaming audio? or both? since the value is a single cell, its a good idea to change the sscanf specifier from "s" to "d" maybe? what if the player inputs a string? then the value is indeed a string:
pawn Код:
value[128]