Help needed? come here i'll try to fix/make it
#1

Hello,
I am bored in making big scripts that take all my time.
I just want to help others.
If you have a bug or a error or something else post it here.
I'll try to fix it and just make it for you, but in a way that you'll learn it too.
I'll explain everything like.
SendClientMessage(playerid,0xAA3333AA,"Hello");//This is a message that'll be send to the player with the text: hello
So any problems? Ask here!
Reply
#2

That really nice of you so i can start :P.

Ive made Kick command now i would like to know how to add Reason to it. here is the code

Код:
dcmd_kick(playerid, params[])
{
	#pragma unused params

	if(admin[playerid] >= 1)
	{
	  new id[256];
		new cmdtext[256];
		new idx;
		new cmd[256];
		cmd = strtok(cmdtext, idx);

	  id = strtok(params, idx);

	  	if(!strlen(id))
	  	{
	  	  SendClientMessage(playerid, COLOR_GOLD, "USAGE: /kick [ID]");
	  	  return 1;
			}
				new pID = strval(id);
				SendClientMessage(pID, COLOR_GOLD, "You have been kicked");
				Kick(pID);
				return 1;
	}
	else
	{
	  SendClientMessage(playerid, COLOR_GOLD, "You are not an admin!");
	}
	return 1;

}
Reply
#3

Could you help me out making a simple RP Firstname_Lastname says:
thanks.
Reply
#4

Код:
	public OnPlayerConnect(playerid)
	{
 	new first[MAX_PLAYER_NAME], last[MAX_PLAYER_NAME];
	if(RPName(PlayerName(playerid),first,last))
	{
	return 0;
	}
	else
	{
 	KickPlayer(playerid,"the server","Invalid Name, Correct Format: Firstname_Lastname");
	}
	return 1;
	}
Код:
RPName(name[],ret_first[],ret_last[])//this will explaine the RPname just put it somewhere but nut in a public{}//
{
	new len = strlen(name),
		point = -1,
		bool:done = false;
	for(new i = 0; i < len; i++)
	{
	  if(name[i] == '_')
	  {
	    if(point != -1) return 0;
	    else {
				if(i == 0) return 0;
				point = i + 1;
			}
	  } else if(point == -1) ret_first[i] = name[i];
	  else {
			ret_last[i - point] = name[i];
			done = true;
		}
This should be the Firstname_Lastname wait for the other script.
Reply
#5

Here you go the /kick playerid reason

Код:
	if(strcmp(cmd, "/kick", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
	  	tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_WHITE, "[Usage:] /kick [playerid/partofname] [reason]");
				return 1;
			}
			giveplayerid = ReturnUser(tmp);
				if(IsPlayerConnected(giveplayerid))
				{
				  if(giveplayerid != INVALID_PLAYER_ID)
				  {
						new length = strlen(cmdtext);
						while ((idx < length) && (cmdtext[idx] <= ' '))
						{
							idx++;
						}
						new offset = idx;
						new result[128];
						while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
						{
							result[idx - offset] = cmdtext[idx];
							idx++;
						}
						result[idx - offset] = EOS;
						if(!strlen(result))
						{
							SendClientMessage(playerid, COLOR_WHITE, "[Usage:] /kick [playerid/partofname] [reason]");
							return 1;
						}
						KickPlayer(giveplayerid,GetPlayerNameEx(playerid),(result));
						return 1;
					}
				}
			}
			else
			{
				SendClientMessage(playerid, COLOR_GREY, "[Error:] Invalid Playerid/Name");
			}
		}
		return 1;
	}
Reply
#6

The Scripting Discussion section is for this.
Reply
#7

Quote:
Originally Posted by ekeleke
Here you go the /kick playerid reason

Код:
	if(strcmp(cmd, "/kick", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
	  	tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_WHITE, "[Usage:] /kick [playerid/partofname] [reason]");
				return 1;
			}
			giveplayerid = ReturnUser(tmp);
				if(IsPlayerConnected(giveplayerid))
				{
				  if(giveplayerid != INVALID_PLAYER_ID)
				  {
						new length = strlen(cmdtext);
						while ((idx < length) && (cmdtext[idx] <= ' '))
						{
							idx++;
						}
						new offset = idx;
						new result[128];
						while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
						{
							result[idx - offset] = cmdtext[idx];
							idx++;
						}
						result[idx - offset] = EOS;
						if(!strlen(result))
						{
							SendClientMessage(playerid, COLOR_WHITE, "[Usage:] /kick [playerid/partofname] [reason]");
							return 1;
						}
						KickPlayer(giveplayerid,GetPlayerNameEx(playerid),(result));
						return 1;
					}
				}
			}
			else
			{
				SendClientMessage(playerid, COLOR_GREY, "[Error:] Invalid Playerid/Name");
			}
		}
		return 1;
	}
It works, yea, but sscanf would have been a shorter and easier sollution for that.

#EDIT#:

Quote:
Originally Posted by Wazza!
The Scripting Discussion section is for this.
True.
Reply
#8

I know that sscanf would be shorter and easier but since he was using strtok i did too and i know this is scripting discussion but this is easier for me i dont like looking in topics with so much posts
Reply
#9

The one who pmed me for animations on his spawn here you go:

Код:
#include<a_samp>

public OnPlayerRequestClass(playerid,classid)// of zoiets wat erop lijkt
{
ApplyAnimation(playerid,"DANCING","dance_loop",4.1,1,1,1,1,1);
return 1;
}

public OnPlayerSpawn(playerid)
{
ClearAnimations(playerid);
return 1;
}
not tested so Don't really know if it works.
Reply
#10

ty it works
Reply
#11

Ok

If someone else needs help just ask
Reply
#12

Код:
	if(strcmp(cmdtext, "/buybomb", true) == 0)
	{
	  if (PlayerToPoint(1, playerid,-50.4694,-233.4252,6.7646))
	  {
  			if(Bomb[playerid] == 1)
			{
				SendClientMessage(playerid, COLOR_GREY, "[Error] You can only carry 1 bomb");
				return 1;
			}
			if(GetPlayerCash(playerid) >= 30000)
			{
				Bomb[playerid] = 1;
				GivePlayerCash(playerid,-30000);
				SendClientMessage(playerid, COLOR_WHITE, "[Success] You bought a bomb, it does not save so use it quickly");
				PlayerActionMessage(playerid,15.0,"gives the business some money and gets a bomb back in return");
				return 1;
		}
		else
		{
		endClientMessage(playerid, COLOR_GREY, "[Error] You do not have enough money");
		return 1;
		}
	}
This gives me LOTS of errors, could you fix it ?
Reply
#13

You didn't close off your command. Add an extra closing bracket ( '}' ) to the end of it.
Reply
#14

Would someone mind helping me with this lil problem?

http://forum.sa-mp.com/index.php?topic=141733.0
Reply
#15

http://forum.sa-mp.com/index.php?topic=141353.0 here? :P
Reply
#16

Please don't put forum links here..
Just give the piece of your code/errors and the problem.
Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)