Posts: 1,461
Threads: 71
Joined: Oct 2010
Quote:
Originally Posted by the_chaoz
De hecho eso no daria tanto lag, aun que esta lejos de ser el mejor codigo.
Aca un buen ejemplo:
pawn Код:
new bool:Driving[MAX_PLAYERS], Weapons[MAX_PLAYERS][13][2];
public OnPlayerStateChange(playerid, newstate, oldstate) { if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER) { for(new i; i<13; i++) { GetPlayerWeaponData(playerid, i, Weapons[playerid][i][0], Weapons[playerid][i][1]); } Driving[playerid] = true; } else if(Driving && (newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)) { for(new i; i<13; i++) { GivePlayerWeapon(playerid, Weapons[playerid][i][0], Weapons[playerid][i][1]); } Driving[playerid] = false; } return 1; }
|
Eso no funcionara, simplemente por que no le remueves las armas y por que la segunda condicion JAMAS se cumplira, ademas no se necesita quitarle las armas, solo con cambiar el arma equipada basta
EJ un poco mas avanzado
pawn Код:
new ForbiddenWeapons[] =
{
24, // Desert Eagle
26, // Recortadas o Sawnoff Shotgun
31 // M4
};
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
new WeaponID = GetPlayerWeapon(playerid);
for(new i; i < sizeof(ForbiddenWeapons); i++) if(WeaponID == ForbiddenWeapons[i])
{
SetPlayerArmedWeapon(playerid, 0);
break;
}
}
return 1;
}