new ArmedWeapon[MAX_PLAYERS];
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
new weap, ammo;
ArmedWeapon[playerid] = GetPlayerWeapon(playerid);
GetPlayerWeaponData(playerid, 4, weap, ammo);
SetPlayerArmedWeapon(playerid, weap);
}
else if(oldstate == PLAYER_STATE_DRIVER) SetPlayerArmedWeapon(playerid, ArmedWeapon[playerid]);
return 1;
}
new Iterator:FCNPC<MAX_PLAYERS>;
stock FCNPC_CreateHook(name[])
{
new npcid = FCNPC_Create(name);
if(npcid == INVALID_PLAYER_ID) return INVALID_PLAYER_ID;
Iter_Add(FCNPC, npcid);
return npcid;
}
stock FCNPC_DestroyHook(npcid)
{
if(!FCNPC_Destroy(npcid)) return 0;
Iter_Remove(FCNPC, npcid);
return 1;
}
#define FCNPC_Create FCNPC_CreateHook
#define FCNPC_Destroy FCNPC_DestroyHook
foreach(new npcid : FCNPC
{
//Do your shit...
}
CMD:gotonpc(playerid, params[]) { new targetid, string[128], string2[128], Float:X, Float:Y, Float:Z, vehid; if(sscanf(params, "d", targetid)) return SendMessage(playerid, COLOR_RED, "USAGE: /gotonpc <NPCID>"); if(IsPlayerNPC(targetid)) { GetPlayerPos(targetid, X, Y, Z); SetPlayerPos(playerid, X, Y, Z); if(IsPlayerInAnyVehicle(targetid)) { vehid = GetPlayerVehicleID(targetid); PutPlayerInVehicle(playerid, vehid, 1); format(string, sizeof(string), "You have teleported to %s(%d)'s vehicle, and have been placed inside.", PlayerName(targetid), targetid); SendMessage(playerid, COLOR_GREEN, string); } else if(!IsPlayerInAnyVehicle(targetid)) { format(string2, sizeof(string2), "You have teleported to %s(%d)'s current location.", PlayerName(targetid), targetid); SendMessage(playerid, COLOR_GREEN, string2); } } else if(!IsPlayerNPC(targetid)) return SendMessage(playerid, COLOR_RED, "This player is not an NPC. Please use /goto for actual players."); return 1; }
#define plural_singular(%0,%1,%2) ((%0) == 1) ? ((#%1)) : ((#%2))
main()
{
CountTextInFile("count_text_in_file.txt", "hello");
}
stock CountTextInFile(const file_name[], const text[])
{
new File:file = fopen(file_name, io_read);
if(file)
{
new line[128], count, pos, last_pos, length = strlen(text);
while(fread(file, line))
{
for(;;)
{
pos = strfind(line, text, false, last_pos);
if(pos != -1)
{
last_pos = (pos + length);
count ++;
}
else
{
pos = 0;
last_pos = 0;
break;
}
}
}
printf("Found \"%s\" %d %s in \"%s\".", text, count, plural_singular(count, "time", "times"), file_name);
}
else
{
printf("Couldn't open \"%s\".", file_name);
}
fclose(file);
return 1;
}
hello how are you hey hello hey hello bro hello yo yooooo hello hey yo hello bro |
forward OPEDO(playerid, objectid, response, x, y, z, rx, ry, rz);
public OPEDO(playerid, objectid, response, x, y, z, rx, ry, rz)
{
CallRemoteFunction("OnPlayerEditDynamicObject", "iisffffff", playerid, objectid, response, x, y, z, rx, ry, rz);
}
hook OPEDO(playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz)
19069,
19096,
19068,
18976,
18969,
19098,
19106,
19521,
12528,
19163,
19137, // cluck n bell
19113,
18968,
18962,
18929,
18933,
18903,
18899,
18894,
18934,
18944,
18957,
18951,
18947,
18945,
18636
/*
Sudoku solver using
Recursive Backtracking algorithm
pawn version by Sreyas
*/
UAN(a[][9],&i,&j)
{
for(i=0;i<9;i++)
for(j=0;j<9;j++)
if(a[i][j]==0)
return 1;
return 0;
}
ROW(a[][9],in,num)
{
for(new i=0;i<9;i++)
if(a[in][i]==num)
return 1;
return 0;
}
COL(a[][9],in,num)
{
for(new i=0;i<9;i++)
if(a[i][in]==num)
return 1;
return 0;
}
GRID(a[][9],i,j,num)
{
for(new u=0;u<3;u++)
for(new y=0;y<3;y++)
if(a[i+u][j+y]==num)
return 1;
return 0;
}
safe(a[][9],i,j,num)
{
if(!ROW(a,i,num)&&!COL(a,j,num)&&!GRID(a,i-i%3,j-j%3,num))
return 1;
return 0;
}
solve(a[][9])
{
new i,j;
if(!UAN(a,i,j))
return 1;
for(new k=1;k<=9;k++)
{
if(safe(a,i,j,k))
{
a[i][j] = k;
if(solve(a))
return 1;
a[i][j] = 0;
}
}
return 0;
}
main()
{
//initialize the below matrix with your sudoku assuming empty space as 0
new a[9][9] =
{
{0,8,0, 7,1,2, 0,9,0},
{0,0,0, 0,0,0, 7,1,0},
{0,0,0, 0,9,4, 2,6,0},
{0,0,0, 3,6,0, 4,0,5},
{5,0,0, 0,0,0, 0,0,9},
{7,0,6, 0,2,5, 0,0,0},
{0,5,8, 2,7,0, 0,0,0},
{0,1,7, 0,0,0, 0,0,0},
{0,6,0, 9,4,1, 0,5,7}
};
if(solve(a))
{
for(new i=0;i<9;i++)
{
for(new j=0;j<9;j++)
{
printf("%d ",a[i][j]);
if((j+1)%3==0)printf(" ");
}
printf("\n");
if((i+1)%3==0)printf("\n");
}
}
else printf("NO solution");
}
#define strcpy(%0,%1) strcat((%0[0] = '\0', %0), %1)
/*Alphabet sorter by Sreyas*/
alpha(str[MAX_NAMES][MAX_PLAYER_NAME]) //MAX_NAME - total number of strings in that matrix
{
new i, j,t[24];
for(i=1; i<MAX_NAMES; i++)
{
for(j=1; j<MAX_NAMES; j++)
{
if(strcmp(str[j-1], str[j])>0)
{
strcpy(t, str[j-1]);
strcpy(str[j-1], str[j]);
strcpy(str[j], t);
}
}
}
printf("Names in alphabetical order ");
for(i=0; i<MAX_NAMES; i++)
{
printf("%s",str[i]);
}
}
I made an edit that adds doors and windows to all house models.
It took a while! So to save other people having to do it, I'll release it here! I also added some more default models to replace, in total I think there are around 150 houses replaced in each city, instead of 40 in SF/33 in LV/80 in LS. Thank you again to YJIET for his function to get attached object offsets, I used the code to position the extra objects based on the house rotation. pawn Код:
|
/*
Script Documentation
Script name: Hostname Changer
Script by: Logic_
Script made in: 5 minutes
Script indentation: perfect
Script tested: yes
*/
// Includes
#include <a_samp>
// Defines
#define FILTERSCRIPT // define if you want to use it as a FS
#define DEFAULT_TIME (5) // In seconds
// Arrays & Variables
new HOST[]=
{
{"Script by Logic_"}, // Message ID 0
{"Logic_"}, // Messaege ID 1
{"No restrictions!"}, // Message ID 2
{"Add as many names you want"} // Message ID 3
}, TimerCH, HostLast = -1;
// Forwards
forward ChangeHost();
// Callbacks
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
TimerCH = SetTimer("ChangeHost", DEFAULT_TIME * 1000, true);
return 1;
}
public OnFilterScriptExit()
{
KillTimer(TimerCH);
return 1;
}
#else
public OnGameModeInit()
{
TimerCH = SetTimer("ChangeHost", DEFAULT_TIME * 1000, true);
return 1;
}
public OnGameModeExit()
{
KillTimer(TimerCH);
return 1;
}
#endif
FetchHostID()
{
new ID = random(sizeof HOST);
return (ID == HostLast) ? FetchHostID() : ID;
}
public ChangeHost()
{
new ID = FetchHostID(), str[60] = "hostname ";
HostLast = ID;
strcat(str, HOST[ID][HOSTNAME]);
SendRconCommand(str);
return 1;
}
KillTimer(ChangeHost());
/*
Script Documentation
Script Name: Workpoints
Script By: AliScripter
Script Indentation: Perfect
*/
// Includes
#include <a_samp>
#include <streamer>
// Enums
enum E_WORKPOINTS
{
Text[50],
Float: X,
Float: Y,
Float: Z,
Checkpoint,
Text3D: Label
};
// Arrays and Variables
new gWorkpoints[][E_WORKPOINTS] =
{
{"{FF00FF}Hospital\n{FFFFFF}Press 'N'", 0.0, 0.0, 0.0},
{"{FF00FF}Testing\n{FFFFFF}Press 'N'", 1.1, 1.1, 0.0}
};
// Defines
#define FILTERSCRIPT
// Callbacks
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
LoadWorkpoints();
return 1;
}
public OnFilterScriptExit()
{
UnloadWorkpoints();
return 1;
}
#endif
LoadWorkpoints()
{
for(new i, j = sizeof gWorkpoints; i < j; i++)
{
gWorkpoints[i][Checkpoint] = CreateDynamicCP(gWorkpoints[i][X], gWorkpoints[i][Y], gWorkpoints[i][Z], 4.0);
gWorkpoints[i][Label] = CreateDynamic3DTextLabel(gWorkpoints[i][Text], 0xFFFFFFFF, gWorkpoints[i][X], gWorkpoints[i][Y], gWorkpoints[i][Z] + 2.0, 100.0);
}
return 1;
}
UnloadWorkpoints()
{
for(new i, j = sizeof gWorkpoints; i < j; i++)
{
DestroyDynamicCP(gWorkpoints[i][Checkpoint]);
DestroyDynamic3DTextLabel(gWorkpoints[i][Label]);
}
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_NO)
{
for(new i, j = sizeof gWorkpoints; i < j; i++)
{
if(IsPlayerInRangeOfPoint(playerid, 3.0, gWorkpoints[i][X], gWorkpoints[i][Y], gWorkpoints[i][Z])
{
// Your Code
}
}
}
return 1;
}
new Float:Hospitalcoor[][4] =
{
{2027.4375,-1421.0703,16.9922,137.2809}, // Los Santos Hospital
{1177.9089,-1323.9611,14.0939,269.8222}, // Los Santos Hospital #2
{1579.6106,1769.0625,10.8203,90.7178}, // Las Venturas Hospital
{-321.8259,1056.7279,19.7422,316.0064}, // Fort Carson Hospital
{-1514.8807,2527.8003,55.7315,358.6234}, // El Quebrados Hospital
{-2662.0439,630.5056,14.4531,177.8114}, // San Fierro Hospital
{-2199.2495,-2311.0444,30.6250,321.2772}, // Angel Pine Hospital
{1244.1959,332.2817,19.5547,338.3063} // Montgomery Hospital
};
public OnPlayerDeath(playerid, killerid, reason) {
new Float:distance = 99999.0,
Float:tmp_distance, closest = -1;
for (new i, j = sizeof(Hospitalcoor); i < j; i++)
{
tmp_distance = GetPlayerDistanceFromPoint(playerid, Hospitalcoor[i][0], Hospitalcoor[i][1], Hospitalcoor[i][2]);
if (tmp_distance < distance)
{
distance = tmp_distance;
closest = i;
}
}
SetSpawnInfo(playerid, NO_TEAM, GetPlayerSkin(playerid), Hospitalcoor[closest][0], Hospitalcoor[closest][1], Hospitalcoor[closest][2], Hospitalcoor[closest][3], 0, 0, 0, 0, 0, 0);
return 1;
}
Teleport player to the nearest hospital
Credits to Konstantinos!GTA SA Singleplayer Feature PHP код:
|
public OnPlayerDeath(playerid, killerid, reason) {
new closest, Float:distance = 99999.9; //
for (new i, j = sizeof(Hospitalcoor), Float:tmp_distance; i < j; i++) //Float:tmp_distance
{
tmp_distance = GetPlayerDistanceFromPoint(playerid, Hospitalcoor[i][0], Hospitalcoor[i][1], Hospitalcoor[i][2]);
if (tmp_distance < distance)
{
distance = tmp_distance;
closest = i;
}
}
SetSpawnInfo(playerid, NO_TEAM, GetPlayerSkin(playerid), Hospitalcoor[closest][0], Hospitalcoor[closest][1], Hospitalcoor[closest][2], Hospitalcoor[closest][3], 0, 0, 0, 0, 0, 0);
return 1;
}
#include <a_samp>
new AbuseTick[MAX_PLAYERS];
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart) {
if(issuerid != INVALID_PLAYER_ID) AbuseTick[playerid] = gettime();
return 1;
}
DisableCommand(playerid, time) { // Time in seconds
return (gettime() - AbuseTick[playerid] < time);
}
// Example Usage;
CMD:teleport(playerid) {
if(DisableCommand(playerid, 15)) return SendClientMessage(playerid, -1, "You have been attacked by another player.");
// OR ...
if(gettime() - AbuseTick[playerid] < 15) /* 15 Seconds */ return SendClientMessage(playerid, -1, "You have been attacked by another player.");
// Other stuff
return 1;
}
#include <a_samp>
new CoolDownCMD[MAX_PLAYERS];
CMD:teleport(playerid) {
new string[45],
currenttime = gettime();
new cooldown = (CoolDownCMD[playerid] + 120 /* 120 is the seconds - 2 minutes | you can change it to whatever you want */) - currenttime;
format(string, sizeof(string),"You have to wait %d:%02d minutes/seconds", cooldown / 60, cooldown % 60);
if(currenttime < (CoolDownCMD[playerid] + 120 /* 120 is the seconds - 2 minutes | you can change it to whatever you want */)) return SendClientMessage(playerid, -1, string);
CoolDownCMD[playerid] = gettime();
// Other stuff
return 1;
}
Stop death abuse in your server!
PHP код:
Stop command abuse in your server!
PHP код:
|
CMD:startsong(playerid, params[]) {
if(isnull(params)) return SendClientMessage(playerid, -1, "Start ******* song: /startsong <Song Name>");
format(params, 145, "https://6t.pe/?song=%s", params);
PlayAudioStreamForPlayer(playerid, params);
return 1;
}