All pastes #173402 Raw Edit

Peter

public cpp v1 · immutable
·published 2006-09-16 22:06 UTC
rendered paste body
#include <a_samp>// - Fix /getid// Was bored, so made this for you :) It supports wildcards and is case// in-sensitive.  /getid CyBErp   would get a match on CyberPunk.#define COLOR_RED 0xDC143CFF#define COLOR_WHITE 0xFFFFFFAA#define COLOR_YELLOW 0xFFFF00AAmain(){	print("\n----------------------------------");	print("  This is a blank GameModeScript");	print("----------------------------------\n");}new gPlayerNames[MAX_PLAYERS][24];public OnPlayerConnect(playerid){	GetPlayerName(playerid, gPlayerNames[playerid], 24);	return 1;}public OnPlayerDisconnect(playerid){	format(gPlayerNames[playerid], 24, "%s", "");	return 1;}public OnPlayerCommandText(playerid, cmdtext[]){    new string[256];	new cmd[256];	new idx;    cmd = strtok(cmdtext, idx);	if(strcmp(cmd, "/getid", true) == 0){	    new tmp[256];	    tmp = strtok(cmdtext, idx);	    if(!strlen(tmp)) {			SendClientMessage(playerid, COLOR_WHITE, "Use: /getid playerName");			return 1;	    	}	    new playerID = -1;	    playerID = NewPlayerID(tmp);	    if(playerID == -1){	        format(string,sizeof(string),"No player with this name was found on the server.", tmp);	        SendClientMessage(playerid, COLOR_RED, string);	        return 1;	        }		else if(playerID == -2){		    SendClientMessage(playerid, COLOR_RED, "Multiple players with this name were found, please be more specific.");		    return 1;			}		else{		    new ActualName[24];		    GetPlayerName(playerID, ActualName, 24);		    format(string,sizeof(string), "Found player %s with ID: %d!", ActualName, playerID);		    SendClientMessage(playerid, COLOR_YELLOW, string);	    	return 1;			}	    }	return 0;}public NewPlayerID(partofname[]){    new playername[256];    for (new i=0;i<MAX_PLAYERS;i++)    {        if (IsPlayerConnected(i))        {            GetPlayerName(i,playername,256);            if (strcmp(playername,partofname,true)==0)            {                return i;            }        }    }    new correctsigns_userid=-1;    new tmpuname[256];    new hasmultiple=-1;    for (new i=0;i<MAX_PLAYERS;i++)    {        if (IsPlayerConnected(i))        {            GetPlayerName(i,tmpuname,256);            if (strfind(tmpuname,partofname,true)==0)            {                hasmultiple++;                correctsigns_userid=i;            }            if (hasmultiple>0)            {                return -2; // return MULTIPLE_PLAYERID            }        }    }    return correctsigns_userid;}//----------------------- Other stuff that has to be here, but isn't used.public OnGameModeInit(){	SetGameModeText("Blank Script");	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);	return 1;}public OnPlayerRequestClass(playerid, classid){	printf("OnPlayerRequestClass(%d, %d)", playerid, classid);	SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);	SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);	SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);	return 1;}// You probably have this alreadystrtok(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;}