SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts

Closed Thread
 
Thread Tools Display Modes
Old 18/06/2006, 11:24 PM   #1
Allan
Little Clucker
 
Join Date: May 2006
Posts: 16
Reputation: 0
Default Useful Commands #1

As posting random "OnPlayerCommandText" is frowned upon in the Useful Functions topic, I thought I'd make a topic for posting some fun/useful/Downright useless functions to add to your OnPlayerCommandText script!

For those in need of it:
strtok:
Code:
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;
}
/lock: Locks Car Doors

Code:
if (strcmp(cmdtext, "/lock", true)==0)
	{
		if(IsPlayerInAnyVehicle(playerid))
		{
			State=GetPlayerState(playerid);
			if(State!=PLAYER_STATE_DRIVER)
			{
				SendClientMessage(playerid,COLOR_GREY,"You can only lock the doors as the driver.");
				return 1;
			}
			new i;
			for(i=0;i<MAX_PLAYERS;i++)
			{
				if(i != playerid)
				{
					SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 1);
				}
			}
			SendClientMessage(playerid, COLOR_GREY, "Vehicle locked!");
			GetPlayerPos(playerid,X,Y,Z);
			PlayerPlaySound(playerid,1056,X,Y,Z);
		}
		else
		{
			SendClientMessage(playerid, COLOR_GREY, "You're not in a vehicle!");
		}
	return 1;
	}
/unlock: Unlocks Car Doors

Code:
	
if (strcmp(cmdtext, "/unlock", true)==0)
	{
		if(IsPlayerInAnyVehicle(playerid))
		{
			State=GetPlayerState(playerid);
			if(State!=PLAYER_STATE_DRIVER)
			{
				SendClientMessage(playerid,COLOR_GREY,"You can only unlock the doors as the driver.");
				return 1;
			}
			new i;
			for(i=0;i<MAX_PLAYERS;i++)
			{
				SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 0);
			}
			SendClientMessage(playerid, COLOR_GREY, "Vehicle unlocked!");
			GetPlayerPos(playerid,X,Y,Z);
			PlayerPlaySound(playerid,1057,X,Y,Z);
		}
		else
		{
			SendClientMessage(playerid, COLOR_GREY, "You're not in a vehicle!");
		}
	return 1;
	}
Allan is offline  
Old 26/06/2006, 10:58 PM   #2
[AU]Ownage
Little Clucker
 
Join Date: Jun 2006
Posts: 5
Reputation: 0
Default Re: Post your Useful/Intresting/Weird OnPlayerCommandText Commands!

this reely helped
[AU]Ownage is offline  
Old 26/06/2006, 11:45 PM   #3
kaka
Little Clucker
 
Join Date: Jun 2006
Posts: 1
Reputation: 0
Default Re: Post your Useful/Intresting/Weird OnPlayerCommandText Commands!

Code:
C:\DOCUME~1\Owner\Desktop\Mano\GTASER~1\GAMEMO~1\src\111.pwn(136) : error 017: undefined symbol "State"
C:\DOCUME~1\Owner\Desktop\Mano\GTASER~1\GAMEMO~1\src\111.pwn(137) : error 017: undefined symbol "State"
C:\DOCUME~1\Owner\Desktop\Mano\GTASER~1\GAMEMO~1\src\111.pwn(139) : error 017: undefined symbol "COLOR_GREY"
C:\DOCUME~1\Owner\Desktop\Mano\GTASER~1\GAMEMO~1\src\111.pwn(150) : error 017: undefined symbol "COLOR_GREY"
C:\DOCUME~1\Owner\Desktop\Mano\GTASER~1\GAMEMO~1\src\111.pwn(151) : error 017: undefined symbol "X"
C:\DOCUME~1\Owner\Desktop\Mano\GTASER~1\GAMEMO~1\src\111.pwn(152) : error 017: undefined symbol "X"
C:\DOCUME~1\Owner\Desktop\Mano\GTASER~1\GAMEMO~1\src\111.pwn(156) : error 017: undefined symbol "COLOR_GREY"
Pawn compiler 3.0.3367			Copyright (c) 1997-2005, ITB CompuPhase


7 Errors.
Not working for me
kaka is offline  
Old 27/06/2006, 01:28 AM   #4
switch
Little Clucker
 
Join Date: Jun 2006
Posts: 21
Reputation: 3
Default Re: Post your Useful/Intresting/Weird OnPlayerCommandText Commands!

Quote:
Originally Posted by kaka
Code:
C:\DOCUME~1\Owner\Desktop\Mano\GTASER~1\GAMEMO~1\src\111.pwn(136) : error 017: undefined symbol "State"
C:\DOCUME~1\Owner\Desktop\Mano\GTASER~1\GAMEMO~1\src\111.pwn(137) : error 017: undefined symbol "State"
C:\DOCUME~1\Owner\Desktop\Mano\GTASER~1\GAMEMO~1\src\111.pwn(139) : error 017: undefined symbol "COLOR_GREY"
C:\DOCUME~1\Owner\Desktop\Mano\GTASER~1\GAMEMO~1\src\111.pwn(150) : error 017: undefined symbol "COLOR_GREY"
C:\DOCUME~1\Owner\Desktop\Mano\GTASER~1\GAMEMO~1\src\111.pwn(151) : error 017: undefined symbol "X"
C:\DOCUME~1\Owner\Desktop\Mano\GTASER~1\GAMEMO~1\src\111.pwn(152) : error 017: undefined symbol "X"
C:\DOCUME~1\Owner\Desktop\Mano\GTASER~1\GAMEMO~1\src\111.pwn(156) : error 017: undefined symbol "COLOR_GREY"
Pawn compiler 3.0.3367			Copyright (c) 1997-2005, ITB CompuPhase


7 Errors.
Not working for me
helps if you know how to code too

I just used this code (thanks Allan) so heres one that will work straight out of the box

in onplayercommandtext:
Code:
//car locking code copied from Allan.
	if (strcmp(cmdtext, "/lock", true)==0)
		{
			if(IsPlayerInAnyVehicle(playerid))
			{
				new State=GetPlayerState(playerid);
				if(State!=PLAYER_STATE_DRIVER)
				{
					SendClientMessage(playerid,0xFFFF00AA,"You can only lock the doors as the driver.");
					return 1;
				}
				new i;
				for(i=0;i<MAX_PLAYERS;i++)
				{
					if(i != playerid)
					{
						SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 1);
					}
				}
				SendClientMessage(playerid, 0xFFFF00AA, "Vehicle locked!");
		  	new Float:pX, Float:pY, Float:pZ;
				GetPlayerPos(playerid,pX,pY,pZ);
				PlayerPlaySound(playerid,1056,pX,pY,pZ);
			}
			else
			{
				SendClientMessage(playerid, 0xFFFF00AA, "You're not in a vehicle!");
			}
		return 1;
		}
		

if (strcmp(cmdtext, "/unlock", true)==0)
	{
		if(IsPlayerInAnyVehicle(playerid))
		{
			new State=GetPlayerState(playerid);
			if(State!=PLAYER_STATE_DRIVER)
			{
				SendClientMessage(playerid,0xFFFF00AA,"You can only unlock the doors as the driver.");
				return 1;
			}
			new i;
			for(i=0;i<MAX_PLAYERS;i++)
			{
				SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 0);
			}
			SendClientMessage(playerid, 0xFFFF00AA, "Vehicle unlocked!");
			new Float:pX, Float:pY, Float:pZ;
			GetPlayerPos(playerid,pX,pY,pZ);
			PlayerPlaySound(playerid,1057,pX,pY,pZ);
		}
		else
		{
			SendClientMessage(playerid, 0xFFFF00AA, "You're not in a vehicle!");
		}
	return 1;
	}
and you you want the for loop in on player exit vehicle.

Code:
public OnPlayerExitVehicle(playerid, vehicleid)
{
	//printf("OnPlayerExitVehicle(%d, %d)", playerid, vehicleid);

	for(new i=0;i<MAX_PLAYERS;i++)
	{
		if(i != playerid)
		{
			SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 0);
		}
	}
	

	return 1;
}
switch is offline  
Old 27/06/2006, 01:51 AM   #5
OffRoader23
Little Clucker
 
Join Date: Jun 2006
Posts: 1
Reputation: 0
Default Re: Post your Useful/Intresting/Weird OnPlayerCommandText Commands!

I got it almost working, but I got these 2 errors within the script:
Code:
D:\Program Files\Rockstar Games\MTASA\samp\gamemodes\src\naziroad.pwn(272) : error 035: argument type mismatch (argument 1)
D:\Program Files\Rockstar Games\MTASA\samp\gamemodes\src\naziroad.pwn(301) : error 035: argument type mismatch (argument 1)
OffRoader23 is offline  
Old 27/06/2006, 02:02 AM   #6
vCE
Little Clucker
 
Join Date: Jun 2006
Posts: 3
Reputation: 0
Default Re: Post your Useful/Intresting/Weird OnPlayerCommandText Commands!

Hidden Command

Code:
	if(strcmp(cmd, "/other", true) == 0 || strcmp(cmd, "/hidden", true) == 0) {
		SendPlayerFormattedText(playerid,"Look at you, you found the hidden command!!!",0);
	return 1;
	}
Don't put this in your /commands or /help.

800 foot fall from your current location

Code:
	if(strcmp(cmd, "/bigfall", true) == 0) {
				if(IsPlayerInAnyVehicle(playerid)) {
				    new Float:X;
					new Float:Y;
					new Float:Z;
				    new VehicleID;
				    GetPlayerPos(playerid, X, Y, Z);
				    VehicleID = GetPlayerVehicleID(playerid);
					SetVehiclePos(VehicleID, X, Y, Z + 800.00);
					SetPlayerFacingAngle(playerid,Ang);
					GivePlayerWeapon(playerid,46,1);
				} else {
					new Float:X;
					new Float:Y;
					new Float:Z;
					GetPlayerPos(playerid, X, Y, Z);
					SetPlayerPos(playerid, X, Y, Z + 800.00);
					SetPlayerFacingAngle(playerid,Ang);
					GivePlayerWeapon(playerid,46,1);
					GameTextForPlayer(playerid, "~w~Weeeeeeeeeeeeeeeeee!!",8000,5);
 				 }
			return 1;
		}
Wtf?

Code:
		else if(strcmp(cmd, "/wtf", true) == 0) {
			if(IsPlayerInAnyVehicle(playerid)) {
					new Float:X;
					new Float:Y;
					new Float:Z;
				  new VehicleID;
				  GetPlayerPos(playerid, X, Y, Z);
				  VehicleID = GetPlayerVehicleID(playerid);
					SetVehiclePos(VehicleID, X, Y, Z + 100000000000000);
					SetPlayerFacingAngle(playerid,Ang);
					SetPlayerInterior(playerid,0);
					GameTextForPlayer(playerid, "~y~OMGWTF~p~BBQ ~r~BIGP3NISLOLRARROF~g~LCOPTER!!11s~w~hift11one",6000,5);
				} else {
					new Float:X;
					new Float:Y;
					new Float:Z;
					GetPlayerPos(playerid, X, Y, Z);
					SetPlayerPos(playerid, X, Y, Z + 100000000000000);
					SetPlayerFacingAngle(playerid,Ang);
					SetPlayerInterior(playerid,0);
					GameTextForPlayer(playerid, "~y~OMGWTF~p~BBQ ~r~BIGP3NISLOLRARROF~g~LCOPTER!!11s~w~hift11one",6000,5);
					}
			return 1;
		}
OMG ITS GONE!!!

Code:
		if(strcmp(cmdtext,"/clearchat",true)==0) // Chat window is gone, fomg!
		{
			SendClientMessage(playerid,COLOR_GREY," ");
			SendClientMessage(playerid,COLOR_GREY," ");
			SendClientMessage(playerid,COLOR_GREY," ");
			SendClientMessage(playerid,COLOR_GREY," ");
			SendClientMessage(playerid,COLOR_GREY," ");
			SendClientMessage(playerid,COLOR_GREY," ");
			SendClientMessage(playerid,COLOR_GREY," ");
			SendClientMessage(playerid,COLOR_GREY," ");
			SendClientMessage(playerid,COLOR_GREY," ");
            SendClientMessage(playerid,COLOR_GREY," ");
		return 1;
		}
i do nothing

Code:
		if(strcmp(cmdtext,"/nothing",true)==0) 
		{
            //do nothing
		return 1;
		}

Speak your soul

Code:
		else if(strcmp(cmd, "/sayall", true) == 0) { //type "/sayall ~r~ Hello bob!" (Edit the MSG and text)
  			new name[256];
  			new tmp[256];
    		new tstring[256];
  			tmp = strtokspace(cmdtext, idx);
  			GetPlayerName(playerid,name,sizeof(name));
  			format(tstring, sizeof(tstring), "*** %s: %s",name,tmp);
  			GameTextForAll(tmp,5000,3);
   		return true;
		}
vCE is offline  
Old 27/06/2006, 02:46 AM   #7
switch
Little Clucker
 
Join Date: Jun 2006
Posts: 21
Reputation: 3
Default Re: Post your Useful/Intresting/Weird OnPlayerCommandText Commands!

Quote:
Originally Posted by OffRoader23
I got it almost working, but I got these 2 errors within the script:
Code:
D:\Program Files\Rockstar Games\MTASA\samp\gamemodes\src\naziroad.pwn(272) : error 035: argument type mismatch (argument 1)
D:\Program Files\Rockstar Games\MTASA\samp\gamemodes\src\naziroad.pwn(301) : error 035: argument type mismatch (argument 1)
assuming you didnt use the one i posted. You need to setup your xyz variables that store where the player is as floats, eg
new Float:X, Float:Y, Float:Z;
instead of
new X, Y, Z;

anyway this thread is about making commands so its time I start thinking of some good ones
switch is offline  
Old 03/07/2006, 11:38 AM   #8
Joshua Yu
Little Clucker
 
Join Date: Jun 2006
Posts: 3
Reputation: 0
Default Teleporting a vehicle just in the front of you.

I have done something similar to something someone has done before. But I just change it a little bit that the vehicle gets into your front using sine and cosine. This is how a mathematician does things!
Code:
	if (strcmp(cmdtext, "/purchase", true)==0) // to set the vehicle that you register to be teleported
	{
	  if (GetPlayerMoney(playerid) < 5000)
	  {
			SendClientMessage(playerid,YELLOW,"Sorry, you don't have enough money to buy a car.");
		}
		else
		{
			if (IsPlayerInAnyVehicle(playerid) == 1)
			{
				SetVehicleToRespawn(ownedcar[playerid]);
				ownedcar[playerid] = GetPlayerVehicleID(playerid);
				owner[ownedcar[playerid]] = playerid;
				SendClientMessage(playerid,YELLOW,"Congragulations! You have purchased a new car.");
				GivePlayerMoney(playerid,-5000);
			}
			else
			{
	      SendClientMessage(playerid,YELLOW,"Please get in a vehicle to buy it.");
			}
		}
		return 1;
	}
	if (strcmp(cmdtext, "/callmycar", true)==0)
	{
	  if (ownedcar[playerid] != 0)
	  {
   	  if (GetPlayerMoney(playerid) < 500)
		  {
				SendClientMessage(playerid,YELLOW,"Sorry, you don't have enough money to use the car teleport service.");
			}
			else
			{
		    new Float:playerpos[4];
		  	GetPlayerPos(playerid,playerpos[0],playerpos[1],playerpos[2]);
		  	GetPlayerFacingAngle(playerid,playerpos[3]);
		  	SetVehicleZAngle(ownedcar[playerid],playerpos[3]+90.0);
		  	SetVehiclePos(ownedcar[playerid],playerpos[0]+3.0*floatsin(-playerpos[3],degrees),playerpos[1]+3.0*floatcos(-playerpos[3],degrees),playerpos[2]+0.5); // This one is cool that I am using trigo functions to set the vehicle just before you.
		  	SendClientMessage(playerid,YELLOW,"Thank you for using car teleport service. Your car has came.");
		  	GivePlayerMoney(playerid,-500);
			}
	  }
		return 1;
	}
Joshua Yu is offline  
Old 04/07/2006, 03:46 AM   #9
Donny_k
Gangsta
 
Donny_k's Avatar
 
Join Date: May 2006
Posts: 788
Reputation: 4
Default Re: Post your Useful/Intresting/Weird OnPlayerCommandText Commands!

A function for displaying my kills/deaths/teamkills, just added it to my script a moment ago.

Some vars :

Code:
//Players kills + deaths vars
new MyKills[MAX_PLAYERS];
new MyDeaths[MAX_PLAYERS];
new MyTeamKills[MAX_PLAYERS];
//Colour
#define COLOR_YELLOW 0xFFFF00AA
The function :

Code:
//ShowScore
ShowScore(playerid)
{
new tmpTotal[128];
format(tmpTotal, sizeof(tmpTotal), "Kills :%d, Deaths :%d, Team Kills :%d", MyKills[playerid], MyDeaths[playerid], MyTeamKills[playerid]);
SendClientMessage(playerid, COLOR_YELLOW, tmpTotal);
}
OnPlayerDeath() :

Code:
MyDeaths[playerid]++; //Put at top of the function under printf(.....)
MyKills[killerid]++;  //I have this under the valid kill section of code
MyTeamKills[killerid]++; //I have this under the invalid(teamkill) section of code
OnPlayerCommandText() :

Code:
//-------------------/score
if(strcmp(cmd, "/score", true) == 0) {
  ShowScore(playerid);
  return 1;
  }
Enjoy...

__________________
We don't stop playing because we grow old, we grow old because we stop playing.
Donny_k is offline  
Old 04/07/2006, 05:37 AM   #10
Whitestrom
Little Clucker
 
Join Date: Jul 2006
Posts: 1
Reputation: 0
Default Re: Post your Useful/Intresting/Weird OnPlayerCommandText Commands!

wach! change day to night or night to day!
Code:
if (strcmp(cmdtext, "/night", true)==0)
	{
	  /* Do something here */
	  SetWorldTime(0);
	  GameTextForPlayer(playerid,"~b~notte ~b~oscura ~g~LOL",5000,5);
	  return 1;
	}
Quote:
if (strcmp(cmdtext, "/day", true)==0)
{
/* Do something here */
SetWorldTime(12);
GameTextForPlayer(playerid,"~p~Giorno ~p~Felice ~p~LOL",5000,5);
return 1;
}
good
Whitestrom is offline  
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Commands abineri Help Archive 5 19/03/2010 01:24 PM
DCMD Commands not working after adding some ZCMD commands :S [L3th4l] Help Archive 4 20/01/2010 10:57 PM
[Help] Some commands cigo Help Archive 2 09/06/2009 08:01 PM
::Need cop commands Can anybody help? :: Battlaman Help Archive 4 22/02/2009 10:08 PM


All times are GMT. The time now is 09:30 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.