23.04.2012, 15:10
You can't compare strings in PAWN with ==. Use strcmp(), it returns 0 if both strings are the same:
Also, tgate isn't a fixed-length array, so it won't be treated as a string:
Should work, untested.
pawn Код:
//Returns 0, success:
strcmp("something", "something");
pawn Код:
//Treated as a integer/char:
new tgate;
//Treated as an integer/char array, we can store strings in there:
new tgate[32];
pawn Код:
CMD:agate(playerid, params[]) {
new tgate[32];
if(PlayerIsL3A(playerid) == 1) {
if(sscanf(params, "s[32]", tgate)) return SendClientMessage(playerid, -1, "USAGE: /agate [gate]");
if( !strcmp(tgate, "a") ) {
if(GateO[0] == false) {
MoveObject(Gate[0], 120.81, 1942.33, 21.63, 2.00);
GateO[0] = true;
} else if (GateO[0] == true) {
MoveObject(Gate[0], 134.67, 1942.33, 21.63, 2.00);
GateO[0] = false;
}
} else if ( !strcmp(tgate, "b") ) {
if(GateO[1] == false) {
MoveObject(Gate[1], 96.93, 1925.09, 18.22, 2.00);
GateO[1] = true;
} else if (GateO[1] == true) {
MoveObject(Gate[1], 96.93, 1922.42, 18.22, 2.00);
GateO[1] = false;
}
} else if ( !strcmp(tgate, "c") ) {
if(GateO[2] == false) {
MoveObject(Gate[2], 286.00, 1834.60, 19.99, 2.00);
GateO[2] = true;
} else if (GateO[2] == true) {
MoveObject(Gate[2], 286.00, 1821.38, 19.99, 2.00);
GateO[2] = false;
}
} else {
SendClientMessage(playerid, COLOR_YELLOW, "[ ! ] The gate ID you provided was invalid.");
}
}
return 1;
}