13.08.2011, 17:09
Hello there,
I'm trying to let an NPC response whenever a player near the NPC says anything in a sentence including 'door'.
I tried three ways, but none of 'em work.
I'd appreciate any help ;d
GetPlayerIDFromName:
I'm trying to let an NPC response whenever a player near the NPC says anything in a sentence including 'door'.
I tried three ways, but none of 'em work.
I'd appreciate any help ;d
Код:
else if((strcmp("door", tmp, true, strlen(tmp)) == 0) && (strlen(tmp) == strlen("door"))) { new NPCID = GetPlayerIDFromName("Cadet_Two"); new Float:x,Float:y,Float:z; GetPlayerPos(NPCID,x,y,z); if(IsPlayerInRangeOfPoint(playerid,15,x,y,z)) //Checking if you're near the NPC { if(!IsACop(playerid) || !IsAnAgent(playerid)) { SetPlayerChatBubble(NPCID, "I'm sorry sir, but you're not an officer", 0xFF0000FF, 100.0, 3000); } else if(SFPD_Door[Opened] == 0) { MoveObject(SFPD_Door[ObjectID3], 253.19029236, 106.5986328125, 1002.21875000, 1.50); MoveObject(SFPD_Door[ObjectID4], 253.19029236, 111.578125, 1002.21875000, 1.50); SFPD_Door[Opened] = 2; SFPD_Door[TimerID]= SetTimer("PDDoorCheck", 5000, 0); MoveObject(SFPD_Door[ObjectID3], 253.19029236, 106.5986328125, 1002.21875000, 1.50); MoveObject(SFPD_Door[ObjectID4], 253.19029236, 111.578125, 1002.21875000, 1.50); SFPD_Door[Opened] = 2; SFPD_Door[TimerID]= SetTimer("PDDoorCheck", 5000, 0); SetPlayerChatBubble(NPCID, "Certainly sir, the doors have been opened.", 0xFF0000FF, 100.0, 3000); } } }
Код:
stock GetPlayerIDFromName(const playername[], partofname=0) { new i; new playername1[64]; for (i=0;i<MAX_PLAYERS;i++) { if (IsPlayerConnected(i)) { GetPlayerName(i,playername1,sizeof(playername1)); if (strcmp(playername1,playername,true)==0) { return i; } } } new correctsigns_userid=-1; new tmpuname[128]; new hasmultiple=-1; if(partofname) { for (i=0;i<MAX_PLAYERS;i++) { if (IsPlayerConnected(i)) { GetPlayerName(i,tmpuname,sizeof(tmpuname)); if(!strfind(tmpuname,playername1[partofname],true, 0)) { hasmultiple++; correctsigns_userid=i; } if (hasmultiple>0) { return -2; } } } } return correctsigns_userid; }