24.02.2010, 10:27
Код:
new cmd[256]; new tmp[256]; new Message[256]; new gMessage[256]; new pName[MAX_PLAYER_NAME+1]; new iName[MAX_PLAYER_NAME+1]; new idx; if(strcmp("/pm", cmd, true) == 0) { tmp = strtok(cmdtext,idx); if(!strlen(tmp) || strlen(tmp) > 5) { SendClientMessage(playerid,YELLOW,"Usage: /pm [id] (Message)"); return 1; } id = strval(tmp); gMessage = strrest(cmdtext,idx); if(!strlen(gMessage)) { SendClientMessage(playerid,YELLOW,"Usage: /pm [id] [Message]"); return 1; } if(!IsPlayerConnected(id)) { SendClientMessage(playerid,YELLOW,"Bad player ID"); return 1; } if(playerid != id) { GetPlayerName(id,iName,sizeof(iName)); GetPlayerName(playerid,pName,sizeof(pName)); format(Message,sizeof(Message),">> %s(%d): %s",iName,id,gMessage); SendClientMessage(playerid,PM_OUTGOING_COLOR,Message); format(Message,sizeof(Message),"** %s(%d): %s",pName,playerid,gMessage); SendClientMessage(id,PM_INCOMING_COLOR,Message); PlayerPlaySound(id,1085,0.0,0.0,0.0); printf("PM: %s",Message); } else { SendClientMessage(playerid,YELLOW,"You cannot PM yourself"); } return 1; } 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; }
This is the code you wanted me to put right?
So i still get these errors
Код:
D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(65) : error 017: undefined symbol "MAX_PLAYER_NAME" D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(66) : error 017: undefined symbol "MAX_PLAYER_NAME" D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(263) : warning 219: local variable "cmd" shadows a variable at a preceding level D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(264) : warning 219: local variable "tmp" shadows a variable at a preceding level D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(265) : warning 219: local variable "Message" shadows a variable at a preceding level D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(266) : warning 219: local variable "gMessage" shadows a variable at a preceding level D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(267) : warning 219: local variable "pName" shadows a variable at a preceding level D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(268) : warning 219: local variable "iName" shadows a variable at a preceding level D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(269) : warning 219: local variable "idx" shadows a variable at a preceding level D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(271) : warning 217: loose indentation D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(271) : error 017: undefined symbol "strtok" D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(271) : error 033: array must be indexed (variable "cmd") D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(288) : error 079: inconsistent return types (array & non-array) D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(304) : error 079: inconsistent return types (array & non-array) D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(309) : error 079: inconsistent return types (array & non-array) D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(313) : error 079: inconsistent return types (array & non-array) D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(315) : error 021: symbol already defined: "cmd" D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(316) : warning 217: loose indentation D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(316) : error 021: symbol already defined: "tmp" D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(317) : error 021: symbol already defined: "Message" D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(318) : error 021: symbol already defined: "gMessage" D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(319) : error 021: symbol already defined: "pName" D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(320) : error 021: symbol already defined: "iName" D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(321) : error 021: symbol already defined: "idx" D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(323) : warning 217: loose indentation D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(325) : error 017: undefined symbol "strtok" D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(325) : error 033: array must be indexed (variable "tmp") D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(328) : error 017: undefined symbol "YELLOW" D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(329) : error 079: inconsistent return types (array & non-array) D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(332) : error 017: undefined symbol "id" D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(333) : error 017: undefined symbol "strrest" D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(333) : error 033: array must be indexed (variable "gMessage") D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(336) : error 017: undefined symbol "YELLOW" D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(337) : error 079: inconsistent return types (array & non-array) D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(340) : error 017: undefined symbol "id" D:\samp03asvr_R4_win32\gamemodes\Untitled.pwn(341) : error 017: undefined symbol "YELLOW" Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 26 Errors.
And how do i fix the MaxPlayers problem