22.04.2011, 07:04
how to script moveable gate only for FBI faction?
if(PlayerInfo[playerid][pFaction] == 2) //Usually FBI ID
#include <a_samp> new gate; new gateopen; public OnFilterScriptInit() { gate = CreateObject(971, 1761.6020507813, -1700.5047607422, 12.527051925659, 0, 0, 269.99996948242); CreateObject(980, 1804.2659912109, -1721.1015625, 13.306594848633, 0, 0, 35; CreateObject(971, 1761.1508789063, -1691.0541992188, 12.497447967529, 0, 0, 269.99450683594); return 1; } public OnPlayerCommandText(playerid, cmdtext[]) { new cmd[256], tmp[256], idx; cmd = strtok(cmdtext, idx); if(strcmp(cmd, "/fbi", true) == 0) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, 0xFFFFFFAA, "USAGE: /fbi [code]"); return 1; } new code; code = strval(tmp); if(code == 123) { if(IsPlayerInRangeOfPoint(playerid, 9.2, 1761.6015625, -1700.50390625, 7.5270519256592)) { if(!gateopen) { MoveObject(gate, 1761.6015625, -1700.50390625, 7.5270519256592, 1.5); gateopen = 1; return 1; } else { MoveObject(gate, 1761.6020507813, -1700.5047607422, 12.527051925659, 1.5); gateopen = 0; return 1; } } else { SendClientMessage(playerid, 0xAFAFAFAA, " You are not near a gate !"); return 1; } } else { SendClientMessage(playerid, 0xAFAFAFAA, " Incorrect code !"); } return 1; } return 0; } strtok(const string[], &index) { new length = strlen(string); while ((index < length) && (string[index] <= ' ')) { index++; } new offset = index; new result[20]; while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1))) { result[index - offset] = string[index]; index++; } result[index - offset] = EOS; return result; } |