[HELP] A Few Requests!
#1

Im working on Scripting An Roleplay Script! NON-GF edit! w00t!

But i need the following to finish it:

- PM System SAMP 0.3 Compatible

- Emergency Radio, for communication between police and fire department.

- Police System, /su , /cuff, /jail, /frisk .etc.....

- Cell Phone System, /call, /sms

- Taxi System, /taxi, /fare


Thank You!

Even if you can only help with one of the problems, thanks!
Reply
#2

You are going to need strtok functions; strtok and bigstrtok


pawn Код:
stock strtok(const string[], &index,seperator=' ')
{
    new length = strlen(string);
    new offset = index;
    new result[128];
    while ((index < length) && (string[index] != seperator) && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }

    result[index - offset] = EOS;
    if ((index < length) && (string[index] == seperator))
    {
        index++;
    }
    return result;
}

stock bigstrtok(const string[], &idx)
{
  new length = strlen(string);
    while ((idx < length) && (string[idx] <= ' '))
    {
        idx++;
    }
    new offset = idx;
    new result[128];
    while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
    {
        result[idx - offset] = string[idx];
        idx++;
    }
    result[idx - offset] = EOS;
    return result;
}
Now add these to the top of your OnPlayerCommandText.

pawn Код:
new cmd[128];
    new tmp[128];
    new idx;
    new string[128];
    cmd = strtok(cmdtext,idx);
Now we have done that here is a /pm [id] [message] system that is compatible with SAMP 0.3a

pawn Код:
if (strcmp("/pm", cmdtext, true, 3) == 0)
  {
    new message[128];
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
          SendClientMessage(playerid,CORAL,"USAGE: /pm [playerid] [message]");
          SendClientMessage(playerid,CORAL,"FUNCTION: Sends a message to a player");
          return 1;
        }
        targetid = strval(tmp);
        if(IsPlayerConnected(targetid))
        {
            new name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME], str[128];
          GetPlayerName(targetid,name,sizeof(name));
          GetPlayerName(playerid,name2,sizeof(name2));
          message = bigstrtok(cmdtext, idx);
          if(!strlen(message)) return SendClientMessage(playerid,CORAL,"USAGE: /pm [playerid] [message]"), SendClientMessage(playerid,CORAL,"You did not enter a message");
          format(string,sizeof(string),"PM from %s(%d): %s",name2, playerid,message);
          SendClientMessage(targetid,YELLOW,string);
            format(str,sizeof(str),"PM sent to %s(%d): %s", name, targetid, message);
            SendClientMessage(playerid,YELLOW,str);
            //printf("[PM] %s[%d] to %s[%d] - %s -",name2, playerid, name, targetid, message);//Un-comment if you want these to be logged into the samp-log.txt
        }
        else if(!IsPlayerConnected(targetid))
        {
            SendClientMessage(playerid,CORAL,"Invalid ID");
            return 1;
        }
    return 1;
    }
Reply
#3

-> Script request topic.
Reply
#4

[b]
Quote:
Originally Posted by Awaran[Enemy-Plus
; ]
You are going to need strtok functions; strtok and bigstrtok


pawn Код:
stock strtok(const string[], &index,seperator=' ')
{
    new length = strlen(string);
    new offset = index;
    new result[128];
    while ((index < length) && (string[index] != seperator) && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }

    result[index - offset] = EOS;
    if ((index < length) && (string[index] == seperator))
    {
        index++;
    }
    return result;
}

stock bigstrtok(const string[], &idx)
{
  new length = strlen(string);
    while ((idx < length) && (string[idx] <= ' '))
    {
        idx++;
    }
    new offset = idx;
    new result[128];
    while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
    {
        result[idx - offset] = string[idx];
        idx++;
    }
    result[idx - offset] = EOS;
    return result;
}
Now add these to the top of your OnPlayerCommandText.

pawn Код:
new cmd[128];
    new tmp[128];
    new idx;
    new string[128];
    cmd = strtok(cmdtext,idx);
Now we have done that here is a /pm [id] [message] system that is compatible with SAMP 0.3a

pawn Код:
if (strcmp("/pm", cmdtext, true, 3) == 0)
  {
    new message[128];
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
          SendClientMessage(playerid,CORAL,"USAGE: /pm [playerid] [message]");
          SendClientMessage(playerid,CORAL,"FUNCTION: Sends a message to a player");
          return 1;
        }
        targetid = strval(tmp);
        if(IsPlayerConnected(targetid))
        {
            new name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME], str[128];
          GetPlayerName(targetid,name,sizeof(name));
          GetPlayerName(playerid,name2,sizeof(name2));
          message = bigstrtok(cmdtext, idx);
          if(!strlen(message)) return SendClientMessage(playerid,CORAL,"USAGE: /pm [playerid] [message]"), SendClientMessage(playerid,CORAL,"You did not enter a message");
          format(string,sizeof(string),"PM from %s(%d): %s",name2, playerid,message);
          SendClientMessage(targetid,YELLOW,string);
            format(str,sizeof(str),"PM sent to %s(%d): %s", name, targetid, message);
            SendClientMessage(playerid,YELLOW,str);
            //printf("[PM] %s[%d] to %s[%d] - %s -",name2, playerid, name, targetid, message);//Un-comment if you want these to be logged into the samp-log.txt
        }
        else if(!IsPlayerConnected(targetid))
        {
            SendClientMessage(playerid,CORAL,"Invalid ID");
            return 1;
        }
    return 1;
    }
I did this:

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	new cmd[128];
	new tmp[128];
	new idx;
	new string[128];
	cmd = strtok(cmdtext,idx);

	if(!strcmp(cmdtext, "/me", true, 3))
  {
    if(!cmdtext[3])return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /me [action]");
    new str[128];
    GetPlayerName(playerid, str, sizeof(str));
    format(str, sizeof(str), "* %s %s", str, cmdtext[4]);
    SendClientMessageToAll(0xFFFF00AA, str);
  if (strcmp("/pm", cmdtext, true, 3) == 0)
  {
    new message[128];
	tmp = strtok(cmdtext, idx);
	if(!strlen(tmp))
	{
	SendClientMessage(playerid,CORAL,"USAGE: /pm [playerid] [message]");
  SendClientMessage(playerid,CORAL,"FUNCTION: Sends a message to a player");
  return 1;
	}
	targetid = strval(tmp);
	if(IsPlayerConnected(targetid))
	{
	new name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME], str[128];
  GetPlayerName(targetid,name,sizeof(name));
  GetPlayerName(playerid,name2,sizeof(name2));
  message = bigstrtok(cmdtext, idx);
  if(!strlen(message)) return SendClientMessage(playerid,CORAL,"USAGE: /pm [playerid] [message]"), SendClientMessage(playerid,CORAL,"You did not enter a message");
  format(string,sizeof(string),"PM from %s(%d): %s",name2, playerid,message);
  SendClientMessage(targetid,YELLOW,string);
	format(str,sizeof(str),"PM sent to %s(%d): %s", name, targetid, message);
	SendClientMessage(playerid,YELLOW,str);
	//printf("[PM] %s[%d] to %s[%d] - %s -",name2, playerid, name, targetid, message);//Un-comment if you want these to be logged into the samp-log.txt
	}
	else if(!IsPlayerConnected(targetid))
	{
	SendClientMessage(playerid,CORAL,"Invalid ID");
	return 1;
	}
[b]and get this error:

Код:
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(136) : error 047: array sizes do not match, or destination array is too small
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(145) : warning 217: loose indentation
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(148) : warning 217: loose indentation
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(148) : error 047: array sizes do not match, or destination array is too small
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(151) : error 017: undefined symbol "CORAL"
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(152) : error 017: undefined symbol "CORAL"
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(155) : error 017: undefined symbol "targetid"
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(156) : error 017: undefined symbol "targetid"
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(158) : warning 219: local variable "str" shadows a variable at a preceding level
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(159) : error 017: undefined symbol "targetid"
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(161) : error 017: undefined symbol "bigstrtok"
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(161) : error 033: array must be indexed (variable "message")
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(162) : error 017: undefined symbol "CORAL"
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(164) : error 017: undefined symbol "targetid"
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(165) : error 017: undefined symbol "targetid"
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(166) : error 017: undefined symbol "YELLOW"
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(169) : error 017: undefined symbol "targetid"
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(171) : error 017: undefined symbol "CORAL"
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(175) : warning 217: loose indentation
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(175) : error 029: invalid expression, assumed zero
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(175) : error 004: function "OnPlayerEnterVehicle" is not implemented
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(180) : warning 225: unreachable code
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(180) : error 029: invalid expression, assumed zero
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(180) : error 004: function "OnPlayerExitVehicle" is not implemented
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(185) : warning 225: unreachable code
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(185) : error 029: invalid expression, assumed zero
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(185) : error 004: function "OnPlayerStateChange" is not implemented
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(190) : warning 225: unreachable code
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(190) : error 029: invalid expression, assumed zero
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(190) : error 004: function "OnPlayerEnterCheckpoint" is not implemented
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(195) : warning 225: unreachable code
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(195) : error 029: invalid expression, assumed zero
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(195) : error 004: function "OnPlayerLeaveCheckpoint" is not implemented
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(200) : warning 225: unreachable code
C:\DOCUME~1\ADMIN~1.GEO\Desktop\COPYOF~1\GAMEMO~1\Country.pwn(200) : error 029: invalid expression, assumed zero

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


26 Errors.
Reply
#5

Just define those colors and replace targetid with playerid, and it should work.
Reply
#6

no... you didnt add new targetid = INVALID_PLAYER_ID; to you OnPlayerCommandText.


here:

Код:
#define WHITE 0xFFFFFFFF
#define GREY 0xAAAAAA
#define RED 0xAA3333AA
#define GREEN 0x33AA33AA
#define YELLOW 0xFFFF00FF
#define BLUE 0x0000BBAA
#define LIGHTBLUE 0x33CCFFAA
#define ORANGE 0xFF9900AA
#define LIME 0x10F441AA
#define MAGENTA 0xFF00FFFF
#define NAVY 0x000080AA
#define AQUA 0xF0F8FFAA
#define CRIMSON 0xDC143CAA
#define FLBLUE 0x6495EDAA
#define BISQUE 0xFFE4C4AA
#define BLACK 0x000000AA
#define CHARTREUSE 0x7FFF00AA
#define BROWN 0xA52A2AAA
#define CORAL 0xEFC286FF
#define GOLD 0xB8860BAA
#define GREENYELLOW 0xADFF2FAA
#define INDIGO 0x4B00B0AA
#define IVORY 0xFFFF82AA
#define LAWNGREEN 0x7CFC00AA
#define LIMEGREEN 0x32CD32AA
#define MIDNIGHTBLUE 0x191970AA
#define MAROON 0x800000AA
#define OLIVE 0x808000AA
#define ORANGERED 0xFF4500AA
#define PINK 0xFFC0CBAA
#define SPRINGGREEN 0x00FF7FAA
#define TOMATO 0xFF6347AA
#define YELLOWGREEN 0x9ACD32AA
#define MEDIUMAQUA 0x83BFBFAA
#define MEDIUMMAGENTA 0x8B008BAA
#define BRIGHTRED 0xDC143CAA
#define SYSTEM 0xEFEFF7AA
#define PURPLE 0x330066AA
#define SAMP 0xA9C4E4AA
#define BLUEGREEN 0x65AA8AFF
#define DARKPURPLE 0x8E6D92FF
#define LOWPURPLE 0x755692FF
Reply
#7

i wouldn't start a rp server witout any rp scripting knowledge
PM System u can find in base fs of samp server(server download from samp site)

and request the rest at the fuking Script Request Topic(Stickied)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)