26.03.2016, 09:20
When should function be public?
When should function be a stock?
When should function be a stock?
With bitwise operation you would basically do the same
Also nearly all colors in sa-mp are stored in RGBA color = 0xFFFF00FF; // Yellow with full alpha First you would extract each color red = color >>> 24; // shifting everything by 24 bits to the right green = color >> 16 & 0xFF; // shifting and extracting the rightmost 8 bit blue = color >> 8 & 0xFF; After that you simply multiply it and check if it went over 255 Additionally be sure that VALUE is a positive number red = min(0xFF, red * VALUE); // same for green and blue At the end you put it together color = red << 24 | green << 16 | blue << 8 | color & 0xFF; |
I'm looking to add a function to darken or lighten a piece of color with a function.
The color is in the format of GetPlayerColor, and I'd like to make it darker or lighter depending on a float value. Example to make a color darker. Code:
ChangeColorIntensity(GetPlayerColor(playerid),0.5) Code:
ChangeColorIntensity(GetPlayerColor(playerid),1.5) |
SetPlayerMarkerVisibility(playerid, alpha = 0xFF) { new oldcolor, newcolor; alpha = clamp(alpha, 0x00, 0xFF); oldcolor = GetPlayerColor(playerid); newcolor = (oldcolor & ~0xFF) | alpha; return SetPlayerColor(playerid, newcolor); }
if i use foreach(Player, i), not need to do
foreach(Player, i){ if(IsPlayerConnected(i)){ I don't need to use isplayerconnected ? |
foreach(new i : Player)
stock HasInsurance(vehicleid)
{
if(!(0 < vehicleid < MAX_VEHICLE)) // checks if the ID is out of bounds
{
print("ERROR: ..."); // catch bad vehicle IDs
// PrintStackTrace(); // find out where HasInsurance was called from so you can fix the bug
return 1;
}
if(!IsValidVehicle(vehicleid)) // checks if the vehicle actually exists
{
print("ERROR: ...");
// PrintStackTrace();
return 1;
}
// perform your actual function
}
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ) { new Float:x, Float:y, Float:z; if(recoil == 1) { GetPlayerCameraFrontVector(playerid, x, y, z); SetPlayerCameraLookAt(playerid, x, y, z + 1.0, CAMERA_MOVE); } return 1; }
So a few days ago i was looking to make a script that would make weapons feel a bit more fleshed out, in the base game weapons don't really have any noticeable recoil besides the spray-pattern, but it still doesn't take that much skill to control your weapon, in games like Ghost Recon Phantoms the recoil is very noticeable and requires you to not only burst-fire but also keep track of how high your aim is getting with each shot.
I wanted to replicate this in SAMP with the camera controls, so i did this: Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ) { new Float:x, Float:y, Float:z; if(recoil == 1) { GetPlayerCameraFrontVector(playerid, x, y, z); SetPlayerCameraLookAt(playerid, x, y, z + 1.0, CAMERA_MOVE); } return 1; } So is there any way you could accomplish what i'm trying to do in SAMP or is it not possible? |
GetPointInFrontOfCamera3D(playerid,&Float:tx,&Float:ty,&Float:tz,Float:radius,&Float:rx=0.0,&Float:rz=0.0);
GetPlayerCameraFrontVector returns a value between -1.0 and 1.0
Use: PHP код:
|
#include <a_samp>
static PlayerAimPunch[MAX_PLAYERS] = {0, ...};
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
if(PlayerAimPunch[playerid] == 0)
PlayerAimPunch[playerid] = 1000;
SetPlayerDrunkLevel(playerid, PlayerAimPunch[playerid]);
PlayerAimPunch[playerid] += 100;
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(!(oldkeys & KEY_FIRE))
{
SetPlayerDrunkLevel(playerid, 0);
PlayerAimPunch[playerid] = 0;
}
return 1;
}
No, not really. When you use SetPlayerCameraLookAt it actually disconnects the camera from the player. One thing you could do is increase the player's "drunk level" for a short time after shooting for a long time which would shift the camera angle without disconnecting it. You have less control over where it's moving this way but it's better than nothing!
|
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
new string[30];
if(Aiming[playerid] == 1)
{
if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_DUCK)
{
switch(weaponid)
{
case 22:
{
SetPlayerDrunkLevel(playerid, 2001);
}
case 23:
{
SetPlayerDrunkLevel(playerid, 2001);
}
case 24:
{
SetPlayerDrunkLevel(playerid, 2001);
}
case 25:
{
SetPlayerDrunkLevel(playerid, 2005);
}
case 26:
{
SetPlayerDrunkLevel(playerid, 2005);
}
case 27:
{
SetPlayerDrunkLevel(playerid, 2005);
}
case 28:
{
SetPlayerDrunkLevel(playerid, 2001);
}
case 29:
{
SetPlayerDrunkLevel(playerid, 2001);
}
case 30:
{
SetPlayerDrunkLevel(playerid, 2001);
}
case 31:
{
SetPlayerDrunkLevel(playerid, 2001);
}
case 32:
{
SetPlayerDrunkLevel(playerid, 2001);
}
case 33:
{
SetPlayerDrunkLevel(playerid, 2005);
}
case 34:
{
SetPlayerDrunkLevel(playerid, 2800);
}
}
}
else
{
switch(weaponid)
{
case 22:
{
SetPlayerDrunkLevel(playerid, 2005);
}
case 23:
{
SetPlayerDrunkLevel(playerid, 2005);
}
case 24:
{
SetPlayerDrunkLevel(playerid, 2005);
}
case 25:
{
SetPlayerDrunkLevel(playerid, 2005);
}
case 26:
{
SetPlayerDrunkLevel(playerid, 2005);
}
case 27:
{
SetPlayerDrunkLevel(playerid, 2005);
}
case 28:
{
SetPlayerDrunkLevel(playerid, 2005);
}
case 29:
{
SetPlayerDrunkLevel(playerid, 2005);
}
case 30:
{
SetPlayerDrunkLevel(playerid, 2005);
}
case 31:
{
SetPlayerDrunkLevel(playerid, 2005);
}
case 32:
{
SetPlayerDrunkLevel(playerid, 2005);
}
case 33:
{
SetPlayerDrunkLevel(playerid, 2005);
}
case 34:
{
SetPlayerDrunkLevel(playerid, 2040);
}
case 35:
{
SetPlayerDrunkLevel(playerid, 2005);
}
case 36:
{
SetPlayerDrunkLevel(playerid, 2005);
}
case 38:
{
SetPlayerDrunkLevel(playerid, 2001);
}
}
}
format(string, sizeof(string), "Drunk Level: %d", GetPlayerDrunkLevel(playerid));
SendClientMessage(playerid, 0xFFFFFF, string);
}
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(PRESSED(KEY_AIM))
{
Aiming[playerid] = 1;
if(GetPlayerWeapon(playerid) == 34)
{
SetPlayerDrunkLevel(playerid, 2070);
}
}
if(RELEASED(KEY_AIM))
{
Aiming[playerid] = 0;
SetPlayerDrunkLevel(playerid, 0);
}
if(RELEASED(KEY_FIRE))
{
SetPlayerDrunkLevel(playerid, 0);
}
return 1;
}
#define FILTERSCRIPT #include <a_samp> #include <zcmd> #if defined FILTERSCRIPT #define PRESSED(%0) \ (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0))) #define RELEASED(%0) \ (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0))) #define HOLDING(%0) \ ((newkeys & (%0)) == (%0)) #define KEY_AIM KEY_HANDBRAKE new Crouching[MAX_PLAYERS]; new StealthKillSetup[MAX_PLAYERS]; new TargetID; new Float: health, Float: ang, Float: x, Float: y, Float: z; public OnFilterScriptInit() { return 1; } public OnFilterScriptExit() { return 1; } #else main() { } #endif public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { if(PRESSED(KEY_FIRE)) { if(StealthKillSetup[playerid] == 1) { ApplyAnimation(playerid, "PED", "GUN_BUTT_crouch", 4.1, 0, 0, 0, 0, 0, 0); GetPlayerTargetPlayer(TargetID); SetPlayerHealth(TargetID, 0); } } if(HOLDING(KEY_JUMP)) { GetPlayerVelocity(playerid, x, y, z); SetPlayerVelocity(playerid, x, y, z + 0.1); } return 1; } CMD:COSOBUFFO(playerid, params[]) { SendClientMessage(playerid, 0xFFFFFF, "X^D"); <-------- Doesn't work for some reason return 1; } public OnPlayerUpdate(playerid) { if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_DUCK) { Crouching[playerid] = 1; } if(Crouching[playerid] == 1 && GetPlayerWeapon(playerid == 0 )) { if(GetPlayerTargetPlayer(playerid) != INVALID_PLAYER_ID) { StealthKillSetup[playerid] = 1; } } return 1; } public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart) { if(weaponid == 54) { ClearAnimations(playerid); GetPlayerFacingAngle(playerid, ang); SetPlayerFacingAngle(playerid, ang + 90); ApplyAnimation(playerid, "ped", "CROUCH_Roll_R", 100, 0, 1, 1, 0, 0, 0); GetPlayerHealth(playerid, health); SetPlayerHealth(playerid, health + amount); } }
Just a fast question, not worth making thread for it;
How can i decrease a specific amount from a MySQL table? Example; I have saved weapon ID 26 with 7 ammo, And i want to take only 3 ammo. so it's gonna be 4 ammo left. How can i decrease it instead of deleting? |
UPDATE `Table` SET `Column` = `Column` - 3 WHERE `Player` = %d