Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #define Rojo 0xFF0000FF
- #define VerdeC 0x00FF00FF
- new Float:Jumping[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- for (new i = 0; i < MAX_PLAYERS; i++)
- {
- if (IsPlayerConnected(i) && !IsPlayerNPC(i))
- {
- Jumping[i] = 0.2;
- }
- }
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- Jumping[playerid] = 0.2;
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new cmd[128], idx;
- cmd = strtok(cmdtext, idx);
- if(strcmp(cmd,"/jumpcar", true) == 0)
- {
- new string[128], tmp[128]; tmp = strtok(cmdtext, idx);
- if(!IsNumeric2(tmp)) return SendClientMessage(playerid, Rojo, "Use: /jumpcar [0.0 - 0.5]");
- new Float:jumping = floatstr(tmp);
- if(jumping < 0.0 || jumping > 0.5) return SendClientMessage(playerid, Rojo, "Use: /jumpcar [0.0 - 0.5]");
- Jumping[playerid] = jumping;
- format(string,128, "* You put your car jump in %0.2f", Jumping[playerid]);
- SendClientMessage(playerid, VerdeC, string);
- return 1;
- }
- return 0;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
- {
- if (newkeys & KEY_CROUCH)
- {
- new Float:x, Float:y, Float:z;
- GetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z);
- SetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z + Jumping[playerid]);
- return 1;
- }
- }
- return 1;
- }
- IsNumeric2(const string[])
- {
- // Is Numeric Check 2
- // ------------------
- // By DracoBlue... handles negative numbers
- new length=strlen(string);
- if (length==0) return false;
- for (new i = 0; i < length; i++)
- {
- if((string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+' && string[i]!='.') // Not a number,'+' or '-' or '.'
- || (string[i]=='-' && i!=0) // A '-' but not first char.
- || (string[i]=='+' && i!=0) // A '+' but not first char.
- ) return false;
- }
- if (length==1 && (string[0]=='-' || string[0]=='+' || string[0]=='.')) return false;
- return true;
- }
- stock strtok(const string[], &index)
- {
- new length = strlen(string);
- while ((index < length) && (string[index] <= ' '))
- {
- index++;
- }
- new offset = index;
- new result[20];
- while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
- {
- result[index - offset] = string[index];
- index++;
- }
- result[index - offset] = EOS;
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment