19.08.2012, 10:05
(
Последний раз редактировалось Gangs_Rocks; 19.08.2012 в 11:28.
)
Usage and explanation of miscellaneous functions - Part 1
Hi there guys, Okay, So I've created this tutorial to explain how you can use miscellaneous functions and use them to make better servers, filterscripts and etc.
This tutorial will include:
1. CreatePickup - Everything about creating pickups
2. SetPlayerSkillLevel - Everything about weapon skill levels and etc.
3. PlayCrimeReportForPlayer - Interesting feature, But sadly, not much used due to unpopularity
1. CreatePickup - Everything about creating pickups
2. SetPlayerSkillLevel - Everything about weapon skill levels and etc.
3. PlayCrimeReportForPlayer - Interesting feature, But sadly, not much used due to unpopularity
__________________________________________________ __________________________________________________ ____________________________________
1. CreatePickup
Syntax: CreatePickup(model, type, Float:X, Float:Y, Float:Z, Virtualworld)
Models : https://sampwiki.blast.hk/wiki/Game_Object_ID_List
P.S: You can make a pickup out of any object, But if you're looking for the mainly used pickups, Have a look here too: http://weedarr.wikidot.com/pickups/
Pickup types: https://sampwiki.blast.hk/wiki/PickupTypes
Making:
Okay, So to make a simple pickup with CreatePickup, You start with declaring a variable.Syntax: CreatePickup(model, type, Float:X, Float:Y, Float:Z, Virtualworld)
Models : https://sampwiki.blast.hk/wiki/Game_Object_ID_List
P.S: You can make a pickup out of any object, But if you're looking for the mainly used pickups, Have a look here too: http://weedarr.wikidot.com/pickups/
Pickup types: https://sampwiki.blast.hk/wiki/PickupTypes
Making:
pawn Код:
new Pickup;
pawn Код:
public OnGameModeInit()
{
pickup = CreatePickup(model, type, Float:X, Float:Y, Float:Z, Virtualworld)
return 1;
}
You'll have something like in savedpositions.txt in "Documents/GTA San Andreas Userfiles/SAMP"
pawn Код:
AddPlayerClass(playerid, 2491.7900, -1668.1653, 13.3438, 269.15, 0, 0, 0, 0, 0, 0);
AddPlayerClass(skin, Float, Float:y, Float:z, Float:Angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo)
What you need is the X, Y and Z
So you just take the
pawn Код:
2491.7900, -1668.1653, 13.3438
pawn Код:
public OnGameModeInit()
{
pickup = CreatePickup(1242, 2 ,2491.7900, -1668.1653, 13.3438, 0)
/// This creates a pickup with model 1242 (Armour) and Spawn type 2 (Respawns after some time) at coords 2491.7900, -1668.1653, 13.3438 with virtual world 0
return 1;
}
Correction:
Quote:
What I've noticed in-game is that some pickups (health, armor) actually DO have their own effect. Or at least with some pickup types. I know this because I was messing around with a function I wrote, OnPlayerArmorChange. When the pickup gets picked up, the player's amor changes to 100.0. On the next tick it changes to 99.9, which is what I've set with SetPlayerArmour in OnPlayerPickUpPickup.
|
We're gonna be using a switch, SendClientMessage and SetPlayerArmour in this part, Make sure you get familiar with them :
SendClientMessage : https://sampwiki.blast.hk/wiki/SendClientMessage
Switch: https://sampwiki.blast.hk/wiki/Control_Structures#switch_2
SetPlayerArmour: https://sampwiki.blast.hk/wiki/SetPlayerArmour
Okay, so we start by creating a switch to switch between the pickup id's.
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
switch(pickupid)
{
case Pickup:
{
// We're gonna do our shit here
}
}
return 1;
}
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == Pickup)
{
// We're gonna do our shit here
}
return 1;
}
So, We start doing some actual stuff now, Which is creating a reaction:
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
switch(pickupid)
{
case Pickup:
{
SetPlayerArmour(playerid, 100); // We set the player armour to 100.
SendClientMessage(playerid, -1, "Congrats! You just picked up my first pickup! Bonus armour for you! "); // We alerted the player that he just picked up our first bonus!
}
}
return 1;
}
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == Pickup)
{
SetPlayerArmour(playerid, 100); // We set the player armour to 100.
SendClientMessage(playerid, -1, "Congrats! You just picked up my first pickup! Bonus armour for you! "); // We alerted the player that he just picked up our first bonus!
}
return 1;
}
__________________________________________________ __________________________________________________ ____________________________________
2. SetPlayerSkillLevel
Syntax: SetPlayerSkillLevel(playerid, skill, level)
Skills: https://sampwiki.blast.hk/wiki/Skillweapons
Level : Ranging from 0 to 1000 , 1000 is hitman skill, which gives bonus
Alright, I'm sure all of you have played single player at SOME point. You should remember that killing random peds around got you weapon skills. Yep, That's what this function is about. It's about creating skills and limiting them.Skills: https://sampwiki.blast.hk/wiki/Skillweapons
Level : Ranging from 0 to 1000 , 1000 is hitman skill, which gives bonus
You might want a simple skill system, or something for your server, which makes the player kill players before getting the bonus for that weapon. This function is meant exactly for that.
Ever wondered why you directly got 2 Tec 9's instead of 1 in SAMP? Because by default, If the scripter DOES NOT set the skill level, It's full by default. Which means you'll automatically get:
2 Sawn offs if you don't use SetSkillLevel
Moving bonus while shooting with many weapons if you don't use SetSkillLevel
And more!
Basically, It's a weapon skill system.
I'd suggest you get more familiar with the weapon skill system here before we proceed further: http://www.gtagaming.com/sanandreas/weaponskills
There's nothing real I can teach you but I'm sure it'll be fun to test this stuff, So, here's what we're gonna do:
We're gonna create 2 simple commands with ZCMD which set the skill of sawn off shotguns and we're gonna test them to know what makes a difference.
I'd like you to get familiar with SendClientMessage,ResetPlayerWeapons, GivePlayerWeapon, ZCMD and SetPlayerSkillLevel before we proceed:
SendClientMessage: https://sampwiki.blast.hk/wiki/SendClientMessage
ZCMD: https://sampwiki.blast.hk/wiki/Zcmd
SetPlayerSkillLevel : https://sampwiki.blast.hk/wiki/SetPlayerSkillLevel
ResetPlayerWeapon : https://sampwiki.blast.hk/wiki/ResetPlayerWeapons
GivePlayerWeapon: https://sampwiki.blast.hk/wiki/GivePlayerWeapon
Alright, I'm not gonna teach you how to create a CMD with ZCMD processor, I'm just gonna jump and straight away explain the code
pawn Код:
CMD:test1(playerid,params[])
{
ResetPlayerWeapons(playerid);
SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 0);
SendClientMessage(playerid, -1, "Sawn off skill set to 0and sawn off given ");
GivePlayerWeapon(playerid, 26, 500);
return 1;
}
CMD:test2(playerid,params[])
{
ResetPlayerWeapons(playerid);
SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 1000);
SendClientMessage(playerid, -1, "Sawn off skill set to 1000 and sawn off given ");
GivePlayerWeapon(playerid, 26, 500);
return 1;
}
Basically, when you type test1, It'll give you 1 sawn off with 1000 ammo, and when you type test2, It'll give you 2 sawn offs with 1000 ammo.
1000 skill level automatically sets your weapon skill to Double Weapon Hitman Skill Level or just Hitman Skill Level and 0 Skill level automatically sets your weapon skill to Poor (Means no bonus)
__________________________________________________ __________________________________________________ ____________________________________
3. PlayCrimeReportForPlayer
Syntax: PlayCrimeReportForPlayer(playerid, suspectid, crimeid)
Okay, lemme explain now
First of all, playerid is the guy who'll hear the report.
Second of all, suspectid is the guy who'll be the suspect in the report.
Third of all, Crimeid is the code/sound/report which will be played.
This function is VERY useful for cops and robbers servers and RP servers as it'll make them more realistic.Okay, lemme explain now
First of all, playerid is the guy who'll hear the report.
Second of all, suspectid is the guy who'll be the suspect in the report.
Third of all, Crimeid is the code/sound/report which will be played.
You can find the crime ID's here: https://sampwiki.blast.hk/wiki/Crime_List
And to make 'em more realistic, You can refer here too : http://www.linuxthefish.net/10-codes.html
Suppose you want to create a case in which a riot is happening, You'll be using CODE: 17 in SAMP or '10-34' code in police language.
pawn Код:
CMD:riot(playerid,params[])
{
PlayCrimeReportForPlayer(playerid, playerid, 17);
SendClientMessage(playerid, -1, "MOTHER OF GOD! NO SHIT, THERE'S A RIOT! ");
return 1;
}
I hope you guys enjoyed the tutorial
P.S: I'm sorry for the untidiness