public OnPlayerRequestClass(playerid, classid)
{
DEBUGF("OnPlayerRequestClass(%d, %d)",playerid, classid);
return 1;
}
} // Leave animation if (strcmp("/stop", cmdtext, true) == 0) { ApplyAnimation(playerid, "CARRY", "crry_prtial", 4.0, 0, 0, 0, 0, 0); // Leave animation SendClientMessage(playerid, 0xFF0000FF, ""); return 1;
new gObjects[ MAX_OBJECTS ]; new TotalObjects = 0;
public IsValidObjectID( objectid ) { if( //weapons ( objectid >= 321 && objectid <= 326 ) || ( objectid >= 330 && objectid <= 331 ) || ( objectid >= 333 && objectid <= 339 ) || ( objectid >= 341 && objectid <= 344 ) || ( objectid >= 346 && objectid <= 363 ) || ( objectid >= 365 && objectid <= 372 ) //fun stuff || ( objectid >= 1433 && objectid <= 13594 ) //roads || ( objectid >= 5482 && objectid <= 5512 ) //barriers || ( objectid >= 966 && objectid <= 998 ) //misc 1210-1325 || ( objectid >= 1210 && objectid <= 1325 ) //misc 1420-1620 || ( objectid >= 1420 && objectid <= 1620 ) //misc 1971-4522 || ( objectid >= 1971 && objectid <= 4522 ) ) { return 1; } return 0; }
public SpawnObject( playerid, modelid ) { if( IsPlayerAdmin( playerid ) == 0 ) { SendClientMessage( playerid, COLOR_RED, "ADMIN ONLY" ); return 0; } if( TotalObjects >= MAX_OBJECTS ) { SendClientMessage( playerid, COLOR_RED, "Too many objects on the map!" ); return 0; } if( IsValidObjectID( modelid ) == 0 ) { SendClientMessage( playerid, COLOR_RED, "Invalid or unsafe model id!" ); return 0; } new Float:SpawnRotZ; if( IsPlayerDriver( playerid ) == 0 ) { new Float:PlayerX, Float:PlayerY, Float:PlayerZ; GetPlayerPos( playerid, PlayerX, PlayerY, PlayerZ ); GetPlayerFacingAngle( playerid, SpawnRotZ ); gObjects[ TotalObjects ] = CreateObject( modelid, PlayerX, PlayerY, PlayerZ, 0.0, 0.0, SpawnRotZ ); SetPlayerPos( playerid, PlayerX, PlayerY, PlayerZ + 10.0 ); } else if( IsPlayerDriver( playerid ) == 1 ) { new Float:CarX, Float:CarY, Float:CarZ; GetVehiclePos( GetPlayerVehicleID( playerid ), CarX, CarY, CarZ ); GetVehicleZAngle( GetPlayerVehicleID( playerid ), SpawnRotZ ); gObjects[ TotalObjects ] = CreateObject( modelid, CarX, CarY, CarZ, 0.0, 0.0, SpawnRotZ ); SetVehiclePos( GetPlayerVehicleID( playerid ), CarX, CarY, CarZ + 10.0 ); } TotalObjects++; new szMsg[ 256 ]; format( szMsg, sizeof( szMsg ), "Model %i ( Object %i ) spawned by admin.", modelid, TotalObjects ); SendClientMessageToAll( COLOR_YELLOW, szMsg ); return 1; }
public DeleteSingleObject( playerid, objectid ) { if( IsPlayerAdmin( playerid ) == 0 ) { SendClientMessage( playerid, COLOR_RED, "ADMIN ONLY" ); return 0; } if( IsValidObject( objectid ) == 1 ) { DestroyObject( objectid ); new szDel[ 256 ]; format( szDel, sizeof( szDel ), "Object id %i deleted by admin!", objectid ); SendClientMessageToAll( COLOR_YELLOW, szDel ); TotalObjects--; return 1; } else { SendClientMessage( playerid, COLOR_RED, "Invalid object id." ); return 0; } return 1; }
public DeleteAllObjects( playerid ) { if( IsPlayerAdmin( playerid ) == 0 ) { SendClientMessage( playerid, COLOR_RED, "ADMIN ONLY" ); return 0; } for( new i = 0; i < MAX_OBJECTS; i++ ) { if( IsValidObject( i ) == 1 ) { DestroyObject( i ); } } SendClientMessageToAll( COLOR_YELLOW, "All objects deleted by admin!" ); TotalObjects = 0; return 1; }
public SpawnRamp( playerid, rampid ) { new nrampid = 1655; switch( rampid ) { case 1: { nrampid = 1655; } case 2: { nrampid = 1473; } case 3: { nrampid = 1474; } case 4: { nrampid = 1475; } case 5: { nrampid = 1477; } default: { nrampid = 1655; } } return SpawnObject( playerid, nrampid ); }
if (strcmp(cmdtext, "/minimad", true)==0) // second command
{
SendClientMessage(playerid, COLOR_GREEN,"GET READY TO BATTLE :D");
GameTextForPlayer(playerid, "Minigun wars!", 5000, 0);
SetPlayerPos(playerid,1410.9625, 667.3798, -193.8245);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, 38, 9000);
return 1;
}
public OnPlayerConnect(playerid)
{
SendDeathMessage(playerid, INVALID_PLAYER_ID, 200);
return 1;
}
public OnPlayerDisconnect(playerid)
{
SendDeathMessage(INVALID_PLAYER_ID, playerid, 201);
}
stock GetRandomID()
{
new randn = random(MAX_PLAYERS);
if(IsPlayerConnected(randn)) return randn;
else
{
return GetRandomID();
}
}
GivePlayerMoney(GetRandomID(), 5000);
static DBWeapon[MAX_PLAYERS],DBAmmo[MAX_PLAYERS];
if(newstate == PLAYER_STATE_DRIVER)
{
GetPlayerWeaponData(playerid,4,DBWeapon[playerid],DBAmmo[playerid]);
SetPlayerAmmo(playerid,DBWeapon[playerid],0);
}
else if(oldstate == PLAYER_STATE_DRIVER)
{
GivePlayerWeapon(playerid,DBWeapon[playerid],DBAmmo[playerid]);
}
on top static DBWeapon[MAX_PLAYERS],DBAmmo[MAX_PLAYERS],PlayerDied[MAX_PLAYERS]; at OnPlayerConnect PlayerDied[playerid] = 0; at OnPlayerDeath PlayerDied[playerid] = 1; at OnPlayerEnterVehicle PlayerDied[playerid] = 0; public OnPlayerStateChange(playerid, newstate, oldstate) { if (newstate == 3) // passenger { GetPlayerWeaponData(playerid,4,DBWeapon[playerid],DBAmmo[playerid]); SetPlayerAmmo(playerid,DBWeapon[playerid],0); } if (newstate == 2) // driver { GetPlayerWeaponData(playerid,4,DBWeapon[playerid],DBAmmo[playerid]); SetPlayerAmmo(playerid,DBWeapon[playerid],0); } if (newstate == 1) // foot { if(PlayerDied[playerid] == 0){ GivePlayerWeapon(playerid,DBWeapon[playerid],DBAmmo[playerid]); } } return 1; }
Originally Posted by tomozj
This gets a randomly selected connected ID. If none is connected, then in theory, it'll keep trying until someone does.
pawn Код:
pawn Код:
|
stock GetRandomID()
{
new bool:connected[MAX_PLAYERS] = false, amount = 0;
for(new i = 0; i < MAX_PLAYERS; i++)
if(IsPlayerConnected(i))
{
connected[i] = true;
amount++;
}
if(amount = 0) return -1;
new rand = random(amount), done = 0;
for(new i = 0; i < MAX_PLAYERS; i++)
if(connected[i])
{
if(done == rand) return i;
done++;
}
return -1;
}
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid) { if (IsPlayerInAnyVehicle(playerid)) { LinkVehicleToInterior(GetPlayerVehicleID(playerid), newinteriorid); } return 1; }
Originally Posted by BlooDsTainD
Servers with looping animations and /stopanim command to stop animations have it just instantly click the character into the default position. with the following animation code you can have them move into the idle position more smoothly without it looking crappy, watch the video if you dont know what i mean, the first example in the video is taken from an existing server, the second is using the following code.
http://www.youtube.com/watch?v=khO6F1gx4cU Код:
} // Leave animation if (strcmp("/stop", cmdtext, true) == 0) { ApplyAnimation(playerid, "CARRY", "crry_prtial", 4.0, 0, 0, 0, 0, 0); // Leave animation SendClientMessage(playerid, 0xFF0000FF, ""); return 1; |
Originally Posted by Salvatore_Salieri
Quote:
How can u make an anim to stop just by pressing a key (for example the RIGHT SHIFT) without using the /stopanim cmd? |
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
for(new i = 0; i < 50; i++)
SendClientMessage(playerid,0xFFFFFFFF," ");
forward DynUpdateStart(playerid);
forward DynUpdateEnd(playerid);
public DynUpdateStart(playerid)
{
TogglePlayerControllable(playerid, false);
new string[255];
format(string, sizeof(string), "~g~Objects~n~~r~Loading");
GameTextForPlayer(playerid, string, 3000, 6);
PlayerPlaySound(playerid, 1056, 0.0, 0.0, 0.0);
SetTimerEx("DynUpdateEnd", 3000, 0,"e",playerid);
return 1;
}
public DynUpdateEnd(playerid)
{
TogglePlayerControllable(playerid, true);
new string[255];
format(string, sizeof(string), "~g~Objects~n~~r~Loaded!");
GameTextForPlayer(playerid, string, 3000, 6);
PlayerPlaySound(playerid, 1056, 0.0, 0.0, 0.0);
return 1;
}
DynUpdateStart(playerid)
public OnPlayerConnect(playerid) { SetTimerEx("MaxPing",15000,0,"d",playerid); return 1; } public MaxPing(playerid) { new PlayerPing = GetPlayerPing(playerid); if (PlayerPing > 550) { SendClientMessage(playerid,COLOR_RED,"Sorry,but your ping is very hight!"); new PlayerName[30], str[256]; GetPlayerName(playerid, PlayerName, 30); format(str, 256, "%s has been kicked for max ping!", PlayerName); SendClientMessageToAll(COLOR_GREEN,str); Kick(playerid); }else{ SendClientMessage(playerid,COLOR_GREEN,"Your ping is normal!;"); } return 1; } |
new bool:B = true;
Test()
{
if (B)
B = false;
else
B = true;
printf( "B is now %s", (B ? ("true") : ("false")) );
}
new bool:B = true;
Test()
{
B = B ? false : true;
printf( "B is now %s", (B ? ("true") : ("false")) );
}
new bool:B = true;
Test()
{
B = !B;
printf( "B is now %s", (B ? ("true") : ("false")) );
}
Originally Posted by [TG
Snipe ]
u guys only need to set a timer to destroy vehicle after 1 second the player have no time to come back i already tested nowone crash |